react-vector-pdf 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,263 +1,263 @@
1
- import H, { createContext as ft, useContext as ct, useState as lt } from "react";
1
+ import $, { createContext as ct, useContext as ft, useState as lt } from "react";
2
2
  import { jsPDF as et } from "jspdf";
3
- var K = { exports: {} }, J = {};
3
+ var K = { exports: {} }, Q = {};
4
4
  var rt;
5
- function ut() {
6
- if (rt) return J;
5
+ function ht() {
6
+ if (rt) return Q;
7
7
  rt = 1;
8
8
  var n = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function r(i, o, f) {
10
- var s = null;
11
- if (f !== void 0 && (s = "" + f), o.key !== void 0 && (s = "" + o.key), "key" in o) {
12
- f = {};
13
- for (var a in o)
14
- a !== "key" && (f[a] = o[a]);
15
- } else f = o;
16
- return o = f.ref, {
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) {
12
+ s = {};
13
+ for (var f in i)
14
+ f !== "key" && (s[f] = i[f]);
15
+ } else s = i;
16
+ return i = s.ref, {
17
17
  $$typeof: n,
18
- type: i,
19
- key: s,
20
- ref: o !== void 0 ? o : null,
21
- props: f
18
+ type: a,
19
+ key: e,
20
+ ref: i !== void 0 ? i : null,
21
+ props: s
22
22
  };
23
23
  }
24
- return J.Fragment = t, J.jsx = r, J.jsxs = r, J;
24
+ return Q.Fragment = t, Q.jsx = r, Q.jsxs = r, Q;
25
25
  }
26
- var Q = {};
26
+ var Z = {};
27
27
  var ot;
28
- function ht() {
28
+ function ut() {
29
29
  return ot || (ot = 1, process.env.NODE_ENV !== "production" && (function() {
30
- function n(e) {
31
- if (e == null) return null;
32
- if (typeof e == "function")
33
- return e.$$typeof === A ? null : e.displayName || e.name || null;
34
- if (typeof e == "string") return e;
35
- switch (e) {
30
+ function n(o) {
31
+ if (o == null) return null;
32
+ if (typeof o == "function")
33
+ return o.$$typeof === E ? null : o.displayName || o.name || null;
34
+ if (typeof o == "string") return o;
35
+ switch (o) {
36
36
  case d:
37
37
  return "Fragment";
38
- case X:
38
+ case L:
39
39
  return "Profiler";
40
- case F:
40
+ case P:
41
41
  return "StrictMode";
42
- case B:
42
+ case X:
43
43
  return "Suspense";
44
- case G:
44
+ case M:
45
45
  return "SuspenseList";
46
- case T:
46
+ case A:
47
47
  return "Activity";
48
48
  }
49
- if (typeof e == "object")
50
- switch (typeof e.tag == "number" && console.error(
49
+ if (typeof o == "object")
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
- ), e.$$typeof) {
53
- case x:
52
+ ), o.$$typeof) {
53
+ case w:
54
54
  return "Portal";
55
- case N:
56
- return e.displayName || "Context";
57
55
  case j:
58
- return (e._context.displayName || "Context") + ".Consumer";
59
- case z:
60
- var u = e.render;
61
- return e = e.displayName, e || (e = u.displayName || u.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
- case q:
63
- return u = e.displayName || null, u !== null ? u : n(e.type) || "Memo";
64
- case v:
65
- u = e._payload, e = e._init;
56
+ return o.displayName || "Context";
57
+ case y:
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;
66
66
  try {
67
- return n(e(u));
67
+ return n(o(c));
68
68
  } catch {
69
69
  }
70
70
  }
71
71
  return null;
72
72
  }
73
- function t(e) {
74
- return "" + e;
73
+ function t(o) {
74
+ return "" + o;
75
75
  }
76
- function r(e) {
76
+ function r(o) {
77
77
  try {
78
- t(e);
79
- var u = !1;
78
+ t(o);
79
+ var c = !1;
80
80
  } catch {
81
- u = !0;
81
+ c = !0;
82
82
  }
83
- if (u) {
84
- u = console;
85
- var h = u.error, g = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
- return h.call(
87
- u,
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,
88
88
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- g
90
- ), t(e);
89
+ C
90
+ ), t(o);
91
91
  }
92
92
  }
93
- function i(e) {
94
- if (e === d) return "<>";
95
- if (typeof e == "object" && e !== null && e.$$typeof === v)
93
+ function a(o) {
94
+ if (o === d) return "<>";
95
+ if (typeof o == "object" && o !== null && o.$$typeof === S)
96
96
  return "<...>";
97
97
  try {
98
- var u = n(e);
99
- return u ? "<" + u + ">" : "<...>";
98
+ var c = n(o);
99
+ return c ? "<" + c + ">" : "<...>";
100
100
  } catch {
101
101
  return "<...>";
102
102
  }
103
103
  }
104
- function o() {
105
- var e = O.A;
106
- return e === null ? null : e.getOwner();
104
+ function i() {
105
+ var o = Y.A;
106
+ return o === null ? null : o.getOwner();
107
107
  }
108
- function f() {
108
+ function s() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function s(e) {
112
- if (E.call(e, "key")) {
113
- var u = Object.getOwnPropertyDescriptor(e, "key").get;
114
- if (u && u.isReactWarning) return !1;
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;
115
115
  }
116
- return e.key !== void 0;
116
+ return o.key !== void 0;
117
117
  }
118
- function a(e, u) {
119
- function h() {
120
- Y || (Y = !0, console.error(
118
+ function f(o, c) {
119
+ function b() {
120
+ D || (D = !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
- u
122
+ c
123
123
  ));
124
124
  }
125
- h.isReactWarning = !0, Object.defineProperty(e, "key", {
126
- get: h,
125
+ b.isReactWarning = !0, Object.defineProperty(o, "key", {
126
+ get: b,
127
127
  configurable: !0
128
128
  });
129
129
  }
130
- function b() {
131
- var e = n(this.type);
132
- return D[e] || (D[e] = !0, console.error(
130
+ function u() {
131
+ var o = n(this.type);
132
+ return k[o] || (k[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
- )), e = this.props.ref, e !== void 0 ? e : null;
134
+ )), o = this.props.ref, o !== void 0 ? o : null;
135
135
  }
136
- function p(e, u, h, g, W, M) {
137
- var C = h.ref;
138
- return e = {
139
- $$typeof: w,
140
- type: e,
141
- key: u,
142
- props: h,
143
- _owner: g
144
- }, (C !== void 0 ? C : null) !== null ? Object.defineProperty(e, "ref", {
136
+ function p(o, c, b, C, F, N) {
137
+ var T = b.ref;
138
+ return o = {
139
+ $$typeof: m,
140
+ type: o,
141
+ key: c,
142
+ props: b,
143
+ _owner: C
144
+ }, (T !== void 0 ? T : null) !== null ? Object.defineProperty(o, "ref", {
145
145
  enumerable: !1,
146
- get: b
147
- }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
146
+ get: u
147
+ }) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
148
148
  configurable: !1,
149
149
  enumerable: !1,
150
150
  writable: !0,
151
151
  value: 0
152
- }), Object.defineProperty(e, "_debugInfo", {
152
+ }), Object.defineProperty(o, "_debugInfo", {
153
153
  configurable: !1,
154
154
  enumerable: !1,
155
155
  writable: !0,
156
156
  value: null
157
- }), Object.defineProperty(e, "_debugStack", {
157
+ }), Object.defineProperty(o, "_debugStack", {
158
158
  configurable: !1,
159
159
  enumerable: !1,
160
160
  writable: !0,
161
- value: W
162
- }), Object.defineProperty(e, "_debugTask", {
161
+ value: F
162
+ }), Object.defineProperty(o, "_debugTask", {
163
163
  configurable: !1,
164
164
  enumerable: !1,
165
165
  writable: !0,
166
- value: M
167
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
166
+ value: N
167
+ }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
168
168
  }
169
- function l(e, u, h, g, W, M) {
170
- var C = u.children;
171
- if (C !== void 0)
172
- if (g)
173
- if (R(C)) {
174
- for (g = 0; g < C.length; g++)
175
- m(C[g]);
176
- Object.freeze && Object.freeze(C);
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);
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 m(C);
182
- if (E.call(u, "key")) {
183
- C = n(e);
184
- var L = Object.keys(u).filter(function(V) {
185
- return V !== "key";
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";
186
186
  });
187
- g = 0 < L.length ? "{key: someKey, " + L.join(": ..., ") + ": ...}" : "{key: someKey}", _[C + g] || (L = 0 < L.length ? "{" + L.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ C = 0 < B.length ? "{key: someKey, " + B.join(": ..., ") + ": ...}" : "{key: someKey}", R[T + C] || (B = 0 < B.length ? "{" + B.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
- g,
195
194
  C,
196
- L,
197
- C
198
- ), _[C + g] = !0);
195
+ T,
196
+ B,
197
+ T
198
+ ), R[T + C] = !0);
199
199
  }
200
- if (C = null, h !== void 0 && (r(h), C = "" + h), s(u) && (r(u.key), C = "" + u.key), "key" in u) {
201
- h = {};
202
- for (var k in u)
203
- k !== "key" && (h[k] = u[k]);
204
- } else h = u;
205
- return C && a(
206
- h,
207
- typeof e == "function" ? e.displayName || e.name || "Unknown" : e
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,
207
+ typeof o == "function" ? o.displayName || o.name || "Unknown" : o
208
208
  ), p(
209
- e,
210
- C,
211
- h,
212
- o(),
213
- W,
214
- M
209
+ o,
210
+ T,
211
+ b,
212
+ i(),
213
+ F,
214
+ N
215
215
  );
216
216
  }
217
- function m(e) {
218
- c(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === v && (e._payload.status === "fulfilled" ? c(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
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));
219
219
  }
220
- function c(e) {
221
- return typeof e == "object" && e !== null && e.$$typeof === w;
220
+ function h(o) {
221
+ return typeof o == "object" && o !== null && o.$$typeof === m;
222
222
  }
223
- var y = H, w = /* @__PURE__ */ Symbol.for("react.transitional.element"), x = /* @__PURE__ */ Symbol.for("react.portal"), d = /* @__PURE__ */ Symbol.for("react.fragment"), F = /* @__PURE__ */ Symbol.for("react.strict_mode"), X = /* @__PURE__ */ Symbol.for("react.profiler"), j = /* @__PURE__ */ Symbol.for("react.consumer"), N = /* @__PURE__ */ Symbol.for("react.context"), z = /* @__PURE__ */ Symbol.for("react.forward_ref"), B = /* @__PURE__ */ Symbol.for("react.suspense"), G = /* @__PURE__ */ Symbol.for("react.suspense_list"), q = /* @__PURE__ */ Symbol.for("react.memo"), v = /* @__PURE__ */ Symbol.for("react.lazy"), T = /* @__PURE__ */ Symbol.for("react.activity"), A = /* @__PURE__ */ Symbol.for("react.client.reference"), O = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, E = Object.prototype.hasOwnProperty, R = Array.isArray, I = console.createTask ? console.createTask : function() {
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() {
224
224
  return null;
225
225
  };
226
- y = {
227
- react_stack_bottom_frame: function(e) {
228
- return e();
226
+ g = {
227
+ react_stack_bottom_frame: function(o) {
228
+ return o();
229
229
  }
230
230
  };
231
- var Y, D = {}, P = y.react_stack_bottom_frame.bind(
232
- y,
233
- f
234
- )(), S = I(i(f)), _ = {};
235
- Q.Fragment = d, Q.jsx = function(e, u, h) {
236
- var g = 1e4 > O.recentlyCreatedOwnerStacks++;
231
+ var D, k = {}, H = g.react_stack_bottom_frame.bind(
232
+ g,
233
+ s
234
+ )(), _ = W(a(s)), R = {};
235
+ Z.Fragment = d, Z.jsx = function(o, c, b) {
236
+ var C = 1e4 > Y.recentlyCreatedOwnerStacks++;
237
237
  return l(
238
- e,
239
- u,
240
- h,
238
+ o,
239
+ c,
240
+ b,
241
241
  !1,
242
- g ? Error("react-stack-top-frame") : P,
243
- g ? I(i(e)) : S
242
+ C ? Error("react-stack-top-frame") : H,
243
+ C ? W(a(o)) : _
244
244
  );
245
- }, Q.jsxs = function(e, u, h) {
246
- var g = 1e4 > O.recentlyCreatedOwnerStacks++;
245
+ }, Z.jsxs = function(o, c, b) {
246
+ var C = 1e4 > Y.recentlyCreatedOwnerStacks++;
247
247
  return l(
248
- e,
249
- u,
250
- h,
248
+ o,
249
+ c,
250
+ b,
251
251
  !0,
252
- g ? Error("react-stack-top-frame") : P,
253
- g ? I(i(e)) : S
252
+ C ? Error("react-stack-top-frame") : H,
253
+ C ? W(a(o)) : _
254
254
  );
255
255
  };
256
- })()), Q;
256
+ })()), Z;
257
257
  }
258
258
  var nt;
259
259
  function dt() {
260
- return nt || (nt = 1, process.env.NODE_ENV === "production" ? K.exports = ut() : K.exports = ht()), K.exports;
260
+ return nt || (nt = 1, process.env.NODE_ENV === "production" ? K.exports = ht() : K.exports = ut()), K.exports;
261
261
  }
262
262
  var U = dt();
263
263
  function tt(n) {
@@ -268,19 +268,29 @@ function tt(n) {
268
268
  left: n.left ?? 0
269
269
  };
270
270
  }
271
- function Z(n) {
272
- const t = n.replace("#", "");
273
- if (t.length === 3) {
274
- const r = parseInt(t[0] + t[0], 16), i = parseInt(t[1] + t[1], 16), o = parseInt(t[2] + t[2], 16);
275
- return [r, i, o];
276
- }
277
- if (t.length === 6) {
278
- const r = parseInt(t.slice(0, 2), 16), i = parseInt(t.slice(2, 4), 16), o = parseInt(t.slice(4, 6), 16);
279
- return [r, i, o];
271
+ function q(n) {
272
+ if (!n) return null;
273
+ if (n.startsWith("#")) {
274
+ const r = n.replace("#", "");
275
+ 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];
278
+ }
279
+ 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];
282
+ }
283
+ 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];
286
+ }
280
287
  }
281
- if (t.length === 8) {
282
- const r = parseInt(t.slice(0, 2), 16), i = parseInt(t.slice(2, 4), 16), o = parseInt(t.slice(4, 6), 16), f = parseInt(t.slice(6, 8), 16) / 255;
283
- return [r, i, o, f];
288
+ const t = n.match(
289
+ /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
290
+ );
291
+ 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];
284
294
  }
285
295
  return null;
286
296
  }
@@ -301,22 +311,22 @@ function it(n, t = !0) {
301
311
  [4, "IV"],
302
312
  [1, "I"]
303
313
  ];
304
- let i = n, o = "";
305
- for (const [f, s] of r)
306
- for (; i >= f; )
307
- o += s, i -= f;
308
- return t ? o : o.toLowerCase();
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();
309
319
  }
310
320
  function st(n, t) {
311
321
  return !t || t === "all" ? !0 : t === "first-only" ? n === 1 : t === "except-first" ? n > 1 : Array.isArray(t) ? t.includes(n) : !0;
312
322
  }
313
323
  class gt {
314
324
  constructor(t = {}) {
315
- this.cursorX = 0, this.cursorY = 0, this.contentWidth = 0, this.margin = { top: 15, right: 15, bottom: 15, left: 15 }, this.defaultFont = {
325
+ this.cursorX = 0, this.cursorY = 0, this.contentWidth = 0, this.reservedBottomHeight = 0, this.margin = { top: 15, right: 15, bottom: 15, left: 15 }, this.defaultFont = {
316
326
  name: void 0,
317
327
  style: "normal",
318
328
  size: 12
319
- }, this.defaultColor = "#111827", this.defaultLineHeight = 1.25, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.generation = 0, this.recurringItems = [], this.options = t, this.margin = t.margin ?? this.margin, this.defaultFont = {
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 = {
320
330
  name: t.font?.name,
321
331
  style: t.font?.style ?? "normal",
322
332
  size: t.font?.size ?? 12
@@ -326,6 +336,22 @@ class gt {
326
336
  orientation: t.orientation ?? "p"
327
337
  }), this.pageWidth = this.pdf.internal.pageSize.getWidth(), this.pageHeight = this.pdf.internal.pageSize.getHeight(), this.resetFlowCursor(), this.applyBaseFont();
328
338
  }
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
+ // Implementation of Stack Methods
343
+ startRecording() {
344
+ this.recordingStack.push([]);
345
+ }
346
+ stopRecording() {
347
+ return this.recordingStack.pop() || [];
348
+ }
349
+ playback(t) {
350
+ t.forEach((r) => r());
351
+ }
352
+ drawOp(t) {
353
+ this.recordingStack.length > 0 ? this.recordingStack[this.recordingStack.length - 1].push(t) : t();
354
+ }
329
355
  get instance() {
330
356
  return this.pdf;
331
357
  }
@@ -345,7 +371,7 @@ class gt {
345
371
  return this.margin.top;
346
372
  }
347
373
  get contentBottom() {
348
- return this.pageHeight - this.margin.bottom;
374
+ return this.pageHeight - this.margin.bottom - this.reservedBottomHeight;
349
375
  }
350
376
  get contentHeight() {
351
377
  return this.contentBottom - this.contentTop;
@@ -359,8 +385,18 @@ class gt {
359
385
  get baseLineHeight() {
360
386
  return this.defaultLineHeight;
361
387
  }
388
+ setReservedHeight(t) {
389
+ this.reservedBottomHeight = t;
390
+ }
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;
393
+ }
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);
397
+ }
362
398
  resetFlowCursor() {
363
- this.cursorX = this.margin.left, this.cursorY = this.margin.top, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right;
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;
364
400
  }
365
401
  reset() {
366
402
  if (this.pdf = new et({
@@ -368,7 +404,7 @@ class gt {
368
404
  format: this.options.format ?? "a4",
369
405
  orientation: this.options.orientation ?? "p"
370
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) {
371
- const t = Z(this.options.color);
407
+ const t = q(this.options.color);
372
408
  t && this.pdf.setTextColor(...t);
373
409
  }
374
410
  this.recurringItems = [];
@@ -377,13 +413,17 @@ class gt {
377
413
  this.headerDrawer = t, this.footerDrawer = r;
378
414
  }
379
415
  applyBaseFont() {
380
- const t = this.defaultFont.name ?? this.pdf.getFont().fontName;
381
- this.pdf.setFont(t, this.defaultFont.style), this.pdf.setFontSize(this.defaultFont.size);
382
- const r = Z(this.defaultColor);
383
- r && this.pdf.setTextColor(...r);
416
+ const t = this.defaultFont.name ?? this.pdf.getFont().fontName, r = this.defaultFont.style, a = this.defaultFont.size, i = this.defaultColor;
417
+ this.drawOp(() => {
418
+ this.pdf.setFont(t, r), this.pdf.setFontSize(a);
419
+ const s = q(i);
420
+ s && this.pdf.setTextColor(...s);
421
+ });
384
422
  }
385
423
  addPage() {
386
- this.pdf.addPage(), this.resetFlowCursor();
424
+ this.drawOp(() => {
425
+ this.pdf.addPage();
426
+ }), this.resetFlowCursor();
387
427
  const t = this.getPageCount();
388
428
  for (const r of this.recurringItems)
389
429
  st(t, r.scope) && (r.draw(), r.y + r.height > this.cursorY && (this.cursorY = r.y + r.height));
@@ -394,92 +434,101 @@ class gt {
394
434
  return;
395
435
  }
396
436
  const r = this.getPageCount();
397
- let i = !0;
398
- for (; i; ) {
399
- i = !1;
400
- for (const o of this.recurringItems)
401
- if (st(r, o.scope) && this.cursorY < o.y + o.height && this.cursorY + t > o.y && (this.cursorY = o.y + o.height, i = !0, this.cursorY + t > this.contentBottom)) {
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)) {
402
442
  this.addPage();
403
443
  return;
404
444
  }
405
445
  }
406
446
  }
407
447
  setTextStyle(t) {
408
- if (t) {
409
- if (t.fontSize && this.pdf.setFontSize(t.fontSize), t.fontStyle) {
410
- const r = this.pdf.getFont().fontName;
411
- this.pdf.setFont(r, t.fontStyle);
448
+ if (!t) return;
449
+ const r = t.fontSize, a = t.fontStyle, i = t.color;
450
+ this.drawOp(() => {
451
+ if (r && this.pdf.setFontSize(r), a) {
452
+ const s = this.pdf.getFont().fontName;
453
+ this.pdf.setFont(s, a);
412
454
  }
413
- if (t.color) {
414
- const r = Z(t.color);
415
- r && (this.pdf.setTextColor(r[0], r[1], r[2]), r[3] !== void 0 ? this.pdf.setGState(
416
- new this.pdf.GState({ opacity: r[3] })
455
+ if (i) {
456
+ const s = q(i);
457
+ s && (this.pdf.setTextColor(s[0], s[1], s[2]), s[3] !== void 0 ? this.pdf.setGState(
458
+ new this.pdf.GState({ opacity: s[3] })
417
459
  ) : this.pdf.setGState(new this.pdf.GState({ opacity: 1 })));
418
460
  }
419
- }
461
+ });
420
462
  }
421
- textRaw(t, r, i, o, f, s = "left") {
422
- this.setTextStyle(o);
423
- const a = { align: s };
424
- typeof f == "number" && (a.maxWidth = f), this.pdf.text(t, r, i, a), this.applyBaseFont();
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);
468
+ }), this.applyBaseFont();
425
469
  }
426
- box(t, r, i, o, f) {
427
- const s = f ?? {};
428
- if (s.fillColor) {
429
- const a = Z(s.fillColor);
430
- a && (a[3] !== void 0 && this.pdf.setGState(
431
- new this.pdf.GState({ opacity: a[3] })
432
- ), this.pdf.setFillColor(a[0], a[1], a[2]), this.pdf.rect(t, r, i, o, "F"), a[3] !== void 0 && this.pdf.setGState(new this.pdf.GState({ opacity: 1 })));
433
- }
434
- if (s.borderWidth || s.borderColor) {
435
- if (s.borderWidth && this.pdf.setLineWidth(s.borderWidth), s.borderColor) {
436
- const a = Z(s.borderColor);
437
- a && (a[3] !== void 0 && this.pdf.setGState(
438
- new this.pdf.GState({ opacity: a[3] })
439
- ), this.pdf.setDrawColor(a[0], a[1], a[2]));
470
+ box(t, r, a, i, s) {
471
+ const e = s ?? {};
472
+ 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]));
479
+ }
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]));
485
+ }
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 }));
440
488
  }
441
- this.pdf.rect(t, r, i, o), this.pdf.setLineWidth(0.2), this.pdf.setDrawColor(0, 0, 0), this.pdf.setGState(new this.pdf.GState({ opacity: 1 }));
442
- }
489
+ });
443
490
  }
444
- line(t, r, i, o) {
445
- this.pdf.line(t, r, i, o);
491
+ line(t, r, a, i) {
492
+ this.drawOp(() => {
493
+ this.pdf.line(t, r, a, i);
494
+ });
446
495
  }
447
496
  async imageFromUrl(t, r = {}) {
448
- const i = (async () => {
497
+ const a = (async () => {
449
498
  try {
450
- const { dataUrl: o, width: f, height: s } = await this.loadImageAsDataURL(t), a = 0.264583, b = f * a, p = s * a;
451
- let l = r.w, m = r.h;
452
- l === void 0 && m === void 0 ? (l = b, m = p) : l === void 0 && m !== void 0 ? l = m * (b / p) : m === void 0 && l !== void 0 && (m = l * (p / b));
453
- const c = l ?? b, y = m ?? p;
454
- let w = r.x, x = r.y ?? this.cursorY;
455
- if (r.y === void 0 && x + y > this.contentBottom && (this.addPage(), x = this.cursorY), w === void 0) {
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) {
456
505
  const d = r.align ?? "left";
457
- d === "left" ? w = this.contentLeft : d === "center" ? w = (this.contentLeft + this.contentRight) / 2 - c / 2 : d === "right" && (w = this.contentRight - c);
506
+ d === "left" ? m = this.contentLeft : d === "center" ? m = (this.contentLeft + this.contentRight) / 2 - h / 2 : d === "right" && (m = this.contentRight - h);
458
507
  }
459
508
  return this.pdf.addImage(
460
- o,
509
+ i,
461
510
  r.mime ?? "PNG",
511
+ m,
462
512
  w,
463
- x,
464
- c,
465
- y
466
- ), { width: c, height: y, x: w, y: x };
467
- } catch (o) {
468
- return console.error("Failed to load image", t, o), { width: 0, height: 0, x: 0, y: 0 };
513
+ 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 };
469
518
  }
470
519
  })();
471
- return this.registerTask(i), i;
520
+ return this.registerTask(a), a;
472
521
  }
473
522
  queueOperation(t) {
474
- const r = this.generation, i = this.opQueue.then(async () => {
523
+ const r = this.generation, a = this.opQueue.then(async () => {
475
524
  if (this.generation === r)
476
525
  try {
477
526
  await t();
478
- } catch (o) {
479
- console.error("Operation failed", o);
527
+ } catch (i) {
528
+ console.error("Operation failed", i);
480
529
  }
481
530
  });
482
- this.opQueue = i, this.registerTask(i);
531
+ this.opQueue = a, this.registerTask(a);
483
532
  }
484
533
  registerTask(t) {
485
534
  this.pendingTasks.add(t), t.finally(() => {
@@ -490,30 +539,33 @@ class gt {
490
539
  await Promise.all(this.pendingTasks), await this.opQueue;
491
540
  }
492
541
  loadImageAsDataURL(t) {
493
- return new Promise((r, i) => {
494
- const o = new Image();
495
- o.crossOrigin = "anonymous", o.onload = () => {
496
- const f = document.createElement("canvas");
497
- f.width = o.width, f.height = o.height;
498
- const s = f.getContext("2d");
499
- if (!s) return i(new Error("Canvas 2D context not available"));
500
- s.drawImage(o, 0, 0), r({
501
- dataUrl: f.toDataURL("image/png"),
502
- width: o.width,
503
- height: o.height
542
+ return new Promise((r, a) => {
543
+ const i = new Image();
544
+ i.crossOrigin = "anonymous", i.onload = () => {
545
+ 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({
550
+ dataUrl: s.toDataURL("image/png"),
551
+ width: i.width,
552
+ height: i.height
504
553
  });
505
- }, o.onerror = (f) => i(f), o.src = t;
554
+ }, i.onerror = (s) => a(s), i.src = t;
506
555
  });
507
556
  }
508
- paragraph(t, r, i) {
509
- const o = i ?? this.contentWidth;
557
+ paragraph(t, r, a) {
558
+ const i = a ?? this.contentWidth;
510
559
  this.setTextStyle(r);
511
- const f = r?.lineHeight ?? this.defaultLineHeight, s = r?.fontSize ?? this.defaultFont.size, a = s * f * 0.3528, b = this.pdf.splitTextToSize(t, o), p = r?.align ?? "left";
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";
512
561
  let l = 0;
513
- return b.forEach((m) => {
514
- this.cursorY + a > this.contentBottom && this.addPage();
515
- const c = this.cursorY + s * 0.3528;
516
- this.pdf.text(m, this.cursorX, c, { align: p, maxWidth: o }), this.cursorY += a, l += a;
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;
517
569
  }), this.cursorY += 1, this.applyBaseFont(), l;
518
570
  }
519
571
  moveCursor(t, r) {
@@ -539,18 +591,18 @@ class gt {
539
591
  this.pdf.setPage(t);
540
592
  }
541
593
  }
542
- measureText(t, r, i) {
594
+ measureText(t, r, a) {
543
595
  this.setTextStyle(r);
544
- const o = r?.fontSize ?? this.defaultFont.size, f = r?.lineHeight ?? this.defaultLineHeight, s = o * f * 0.3528;
545
- if (i) {
546
- const a = this.pdf.splitTextToSize(t, i);
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);
547
599
  return {
548
- width: i,
549
- height: a.length * s
600
+ width: a,
601
+ height: f.length * e
550
602
  };
551
603
  } else {
552
- const a = this.pdf.getTextDimensions(t);
553
- return { width: a.w, height: a.h };
604
+ const f = this.pdf.getTextDimensions(t);
605
+ return { width: f.w, height: f.h };
554
606
  }
555
607
  }
556
608
  setMetadata(t) {
@@ -564,174 +616,192 @@ class gt {
564
616
  getBlobUrl() {
565
617
  return this.applyHeaderFooter(), this.pdf.output("bloburl");
566
618
  }
619
+ /**
620
+ * Injects a filled rectangle at the beginning of the page stream.
621
+ * This ensures the background is drawn BEHIND all other content on the page.
622
+ */
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(" "));
634
+ }
567
635
  }
568
- const at = ft(null), $ = () => {
569
- const n = ct(at);
636
+ const at = ct(null), V = () => {
637
+ const n = ft(at);
570
638
  if (!n) throw new Error("usePdf must be used within <PdfDocument>");
571
639
  return n;
572
640
  }, pt = ({
573
641
  options: n,
574
642
  header: t,
575
643
  footer: r,
576
- pageNumbers: i,
577
- centerLabel: o,
578
- metadata: f,
579
- children: s,
580
- onReady: a,
581
- filename: b,
644
+ pageNumbers: a,
645
+ centerLabel: i,
646
+ metadata: s,
647
+ children: e,
648
+ onReady: f,
649
+ filename: u,
582
650
  autoSave: p = !1
583
651
  }) => {
584
- const l = H.useMemo(() => new gt(n), [n]);
585
- return H.useEffect(() => {
586
- f && l.setMetadata(f);
587
- }, [l, f]), H.useEffect(() => {
588
- const m = (x, d) => !d || d === "all" ? !0 : d === "first-only" ? x === 1 : d === "except-first" ? x > 1 : Array.isArray(d) ? d.includes(x) : !0, c = (x, d) => d === "roman-upper" ? it(x, !0) : d === "roman-lower" ? it(x, !1) : String(x), y = (x, d, F) => {
589
- if (!i?.enabled || !m(d, i.scope)) return;
590
- const X = i.preset ?? "page-slash-total", N = (i.template ?? (X === "page-slash-total" ? "Page {page}/{total}" : X === "page-of-total" ? "Page {page} of {total}" : "{page}/{total}")).replace("{page}", c(d, i.format)).replace("{total}", c(F, i.format)), z = i.align ?? "right", B = z === "left" ? l.contentLeft + (i.offsetX ?? 0) : z === "right" ? l.contentRight - (i.offsetX ?? 0) : (l.contentLeft + l.contentRight) / 2 + (i.offsetX ?? 0), G = x === "header" ? 10 : l.height - 7, q = typeof i.y == "number" ? i.y : G;
591
- l.textRaw(N, B, q, i.style, void 0, z);
592
- }, w = (x, d, F) => {
593
- if (!o?.enabled || !m(d, o.scope)) return;
594
- const X = "center", j = (l.contentLeft + l.contentRight) / 2 + (o.offsetX ?? 0), N = x === "header" ? 10 : l.height - 7, z = typeof o.y == "number" ? o.y : N;
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;
595
663
  l.textRaw(
596
- o.text,
597
- j,
598
- z,
599
- o.style,
664
+ i.text,
665
+ y,
666
+ I,
667
+ i.style,
600
668
  void 0,
601
- X
669
+ L
602
670
  );
603
671
  };
604
672
  return l.setHeaderFooter(
605
- (x, d, F) => {
606
- t && t(l, d, F), i?.position === "header" && y("header", d, F), o?.position === "header" && w("header", d);
673
+ (w, d, P) => {
674
+ t && t(l, d, P), a?.position === "header" && g("header", d, P), i?.position === "header" && m("header", d);
607
675
  },
608
- (x, d, F) => {
609
- i?.position === "footer" && y("footer", d, F), r && r(l, d, F), o?.position === "footer" && w("footer", d);
676
+ (w, d, P) => {
677
+ a?.position === "footer" && g("footer", d, P), r && r(l, d, P), i?.position === "footer" && m("footer", d);
610
678
  }
611
679
  ), l.waitForTasks().then(() => {
612
- a?.(l);
680
+ f?.(l);
613
681
  }), () => {
614
682
  l.reset();
615
683
  };
616
- }, [l]), H.useEffect(() => {
617
- p && b && l.save(b);
618
- }, [p, b]), /* @__PURE__ */ U.jsx(at.Provider, { value: l, children: s });
619
- }, St = ({
684
+ }, [l]), $.useEffect(() => {
685
+ p && u && l.save(u);
686
+ }, [p, u]), /* @__PURE__ */ U.jsx(at.Provider, { value: l, children: e });
687
+ }, Rt = ({
620
688
  src: n,
621
689
  x: t,
622
690
  y: r,
623
- w: i,
624
- h: o,
625
- mime: f = "PNG",
626
- flow: s,
627
- layout: a,
628
- sizing: b,
691
+ w: a,
692
+ h: i,
693
+ mime: s = "PNG",
694
+ flow: e,
695
+ layout: f,
696
+ sizing: u,
629
697
  align: p = "left",
630
698
  showInAllPages: l,
631
- scope: m
699
+ scope: x
632
700
  }) => {
633
- const c = $();
634
- return H.useEffect(() => {
635
- const y = a === "flow" || s === !0 || t === void 0 && r === void 0 && a !== "fixed";
636
- let w = i;
637
- b === "fill" && (w = c.contentAreaWidth);
638
- const x = t, d = r;
639
- c.queueOperation(async () => {
640
- const F = c.getCursor(), j = await (async (N, z) => {
641
- const B = x, G = d;
642
- return await c.imageFromUrl(n, {
643
- x: B,
644
- y: G,
645
- w,
646
- h: o,
647
- mime: f,
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,
715
+ mime: s,
648
716
  align: p
649
717
  });
650
718
  })();
651
- y && j && c.moveCursor(0, j.height + 2), l && j && c.registerRecurringItem({
719
+ g && y && h.moveCursor(0, y.height + 2), l && y && h.registerRecurringItem({
652
720
  draw: () => {
653
- c.queueOperation(async () => {
654
- y && c.setCursor(F.x, F.y), await c.imageFromUrl(n, {
655
- x,
656
- y: y ? F.y : d,
657
- w,
658
- h: o,
659
- mime: f,
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,
727
+ mime: s,
660
728
  align: p
661
729
  });
662
730
  });
663
731
  },
664
- scope: m ?? "all",
665
- y: y ? F.y : d ?? 0,
666
- height: j.height + 2
732
+ scope: x ?? "all",
733
+ y: g ? P.y : d ?? 0,
734
+ height: y.height + 2
667
735
  });
668
736
  });
669
737
  }, [
670
- c,
738
+ h,
671
739
  n,
672
740
  t,
673
741
  r,
742
+ a,
674
743
  i,
675
- o,
676
- f,
677
744
  s,
678
- a,
679
- b,
745
+ e,
746
+ f,
747
+ u,
680
748
  p,
681
749
  l,
682
- m
750
+ x
683
751
  ]), null;
684
- }, Rt = ({
752
+ }, St = ({
685
753
  items: n,
686
754
  ordered: t = !1,
687
755
  style: r,
688
- indent: i = 5,
689
- markerWidth: o = 5,
690
- spacing: f = 2
756
+ indent: a = 5,
757
+ markerWidth: i = 5,
758
+ spacing: s = 2
691
759
  }) => {
692
- const s = $();
693
- return H.useEffect(() => {
694
- s.queueOperation(() => {
695
- n.forEach((a, b) => {
696
- const p = t ? `${b + 1}.` : "•", l = s.getCursor().y, m = s.getCursor().x, c = m + i + o, y = r?.fontSize ?? s.baseFont.size, w = l + y * 0.3528;
697
- s.textRaw(
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(
698
768
  p,
699
- m + i,
700
- w,
769
+ m + a,
770
+ d,
701
771
  r,
702
- o,
772
+ i,
703
773
  "right"
704
- ), s.setCursor(c, l);
705
- const x = s.contentRight - c;
706
- s.paragraph(a, r, x);
707
- const d = s.getCursor().y;
708
- s.setCursor(m, d + f);
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);
709
779
  });
710
780
  });
711
- }, [s, n, t, r, i, o, f]), null;
712
- }, xt = ({
781
+ }, [e, n, t, r, a, i, s]), null;
782
+ }, Tt = ({
713
783
  width: n = "inherit",
714
784
  height: t = "inherit",
715
785
  className: r,
716
- style: i,
717
- iframeClassName: o,
718
- iframeStyle: f,
719
- ...s
786
+ style: a,
787
+ iframeClassName: i,
788
+ iframeStyle: s,
789
+ ...e
720
790
  }) => {
721
- const [a, b] = lt(null), p = (l) => {
722
- const m = l.getBlobUrl();
723
- b(m.toString());
791
+ const [f, u] = lt(null), p = (l) => {
792
+ const x = l.getBlobUrl();
793
+ u(x.toString());
724
794
  };
725
- return /* @__PURE__ */ U.jsxs("div", { className: r, style: { width: n, height: t, ...i }, children: [
726
- /* @__PURE__ */ U.jsx("div", { style: { display: "none" }, children: /* @__PURE__ */ U.jsx(pt, { ...s, onReady: p, autoSave: !1, children: s.children }) }),
727
- a ? /* @__PURE__ */ U.jsx(
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(
728
798
  "iframe",
729
799
  {
730
- src: a,
800
+ src: f,
731
801
  width: "100%",
732
802
  height: "100%",
733
- className: o,
734
- style: { border: "none", ...f },
803
+ className: i,
804
+ style: { border: "none", ...s },
735
805
  title: "PDF Preview"
736
806
  }
737
807
  ) : /* @__PURE__ */ U.jsx(
@@ -750,237 +820,286 @@ const at = ft(null), $ = () => {
750
820
  }
751
821
  )
752
822
  ] });
753
- }, Ct = ({
823
+ }, Pt = ({
754
824
  data: n,
755
825
  columns: t,
756
826
  width: r = "100%",
757
- borderWidth: i = 0.1,
758
- borderColor: o = "#000000",
759
- cellPadding: f = 2,
760
- headerStyle: s,
761
- rowStyle: a,
762
- alternateRowStyle: b,
827
+ borderWidth: a = 0.1,
828
+ borderColor: i = "#000000",
829
+ cellPadding: s = 2,
830
+ headerStyle: e,
831
+ rowStyle: f,
832
+ alternateRowStyle: u,
763
833
  headerHeight: p,
764
834
  repeatHeader: l = !0,
765
- striped: m = !1
835
+ striped: x = !1
766
836
  }) => {
767
- const c = $();
768
- return H.useEffect(() => {
769
- c.queueOperation(() => {
770
- const y = typeof r == "number" ? r : parseFloat(r) / 100 * c.contentAreaWidth, w = t.map((v) => typeof v.width == "number" ? v.width : typeof v.width == "string" && v.width.endsWith("%") ? parseFloat(v.width) / 100 * y : 0), x = w.reduce((v, T) => v + T, 0), d = Math.max(0, y - x), F = w.filter((v) => v === 0).length;
771
- if (F > 0) {
772
- const v = d / F;
773
- for (let T = 0; T < w.length; T++)
774
- w[T] === 0 && (w[T] = v);
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);
775
845
  }
776
- const X = (v, T, A, O, E, R, I = "left", Y = !0) => {
777
- Y && c.box(T, A, O, E, {
778
- borderColor: R.borderColor ?? o,
779
- borderWidth: R.borderWidth ?? i,
780
- fillColor: R.fillColor
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
781
851
  });
782
- const D = tt(R.padding ?? f), P = {
783
- top: R.paddingTop ?? D.top,
784
- right: R.paddingRight ?? D.right,
785
- bottom: R.paddingBottom ?? D.bottom,
786
- left: R.paddingLeft ?? D.left
787
- }, S = O - P.left - P.right, _ = c.instance.splitTextToSize(v, S, R), e = (R.fontSize ?? c.baseFont.size) * (R.lineHeight ?? c.baseLineHeight) * 0.3528, u = (R.fontSize ?? c.baseFont.size) * 0.3528, h = _.length * e, g = E - P.top - P.bottom;
788
- let W = 0;
789
- R.verticalAlign === "middle" ? W = Math.max(0, (g - h) / 2) : R.verticalAlign === "bottom" && (W = Math.max(0, g - h));
790
- let M = A + P.top + W + u;
791
- const C = R.align ?? I, L = c.getCursor();
792
- _.forEach((k) => {
793
- let V = T + P.left;
794
- C === "center" ? V = T + O / 2 : C === "right" && (V = T + O - P.right), c.textRaw(k, V, M, R, void 0, C), M += e;
795
- }), c.setCursor(L.x, L.y);
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);
796
866
  };
797
- let j = c.getCursor().y;
798
- const N = c.getCursor().x, z = p ?? 10;
799
- j + z > c.contentBottom && (c.addPage(), j = c.getCursor().y);
800
- let B = N;
801
- t.forEach((v, T) => {
802
- const A = w[T];
803
- X(
804
- v.header ?? "",
805
- B,
806
- j,
807
- A,
808
- z,
809
- s ?? { fontStyle: "bold" },
810
- v.align ?? "left"
811
- ), B += A;
812
- }), j += z, c.setCursor(N, j);
813
- const G = (v, T, A) => {
814
- const O = tt(f), E = {
815
- top: A.paddingTop ?? O.top,
816
- right: A.paddingRight ?? O.right,
817
- bottom: A.paddingBottom ?? O.bottom,
818
- left: A.paddingLeft ?? O.left
819
- }, R = T - E.left - E.right;
820
- return c.measureText(v, A, R).height + E.top + E.bottom;
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;
821
891
  };
822
892
  new Array(t.length).fill(0), (() => {
823
- const v = new Array(n.length).fill(0);
824
- for (let E = 0; E < n.length; E++) {
825
- const R = n[E];
826
- let I = 0;
827
- for (let Y = 0; Y < t.length; Y++) {
828
- const D = t[Y], P = typeof D.accessor == "function" ? D.accessor(R) : R[D.accessor];
829
- let S = "", _ = a, e = 1, u = 1;
830
- if (P && typeof P == "object" && P.content !== void 0 ? (S = String(P.content), P.style && (_ = P.style), P.colSpan && (e = P.colSpan), P.rowSpan && (u = P.rowSpan)) : S = String(P ?? ""), u > 1) {
831
- Y += e - 1;
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;
832
912
  continue;
833
913
  }
834
- let h = w[Y];
835
- for (let W = 1; W < e; W++)
836
- Y + W < w.length && (h += w[Y + W]);
837
- const g = G(S, h, _ ?? {});
838
- g > I && (I = g), Y += e - 1;
914
+ const F = M(R, C, o ?? {});
915
+ F > D && (D = F), k += c - 1;
839
916
  }
840
- I < 8 && (I = 8), v[E] = I;
917
+ D < 8 && (D = 8), S[v] = D;
841
918
  }
842
- let T = j;
843
- const A = new Array(t.length).fill(0), O = c.getCursor().x;
844
- for (let E = 0; E < n.length; E++) {
845
- const R = n[E], I = v[E];
846
- let Y = I;
847
- for (let S = 0; S < t.length; S++) {
848
- const _ = t[S], e = typeof _.accessor == "function" ? _.accessor(R) : R[_.accessor];
849
- let u = 1;
850
- if (e && typeof e == "object" && e.rowSpan && (u = e.rowSpan), u > 1) {
851
- let h = 0;
852
- for (let g = 0; g < u; g++)
853
- E + g < v.length && (h += v[E + g]);
854
- h > Y && (Y = h);
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;
927
+ }
928
+ });
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);
855
942
  }
856
943
  }
857
- const D = Math.abs(T - (c.contentTop + (p ?? 10))) < 1;
858
- if (T + Y > c.contentBottom && !D && (c.addPage(), T = c.getCursor().y, l && (p ?? 10) !== 0)) {
859
- let S = O;
860
- t.forEach((_, e) => {
861
- const u = w[e];
862
- X(
863
- _.header ?? "",
864
- S,
865
- T,
866
- u,
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,
867
954
  p ?? 10,
868
- s ?? { fontStyle: "bold" },
869
- _.align ?? "left"
870
- ), S += u;
871
- }), T += p ?? 10;
955
+ e ?? { fontStyle: "bold" },
956
+ o.align ?? "left"
957
+ ), R += b;
958
+ }), E += p ?? 10;
872
959
  }
873
- let P = O;
874
- for (let S = 0; S < t.length; S++) {
875
- if (A[S] > 0) {
876
- A[S]--, P += w[S];
960
+ let _ = z;
961
+ for (let R = 0; R < t.length; R++) {
962
+ if (Y[R] > 0) {
963
+ Y[R]--, _ += m[R];
877
964
  continue;
878
965
  }
879
- const _ = t[S], e = typeof _.accessor == "function" ? _.accessor(R) : R[_.accessor];
880
- let u = 1, h = 1, g = a;
881
- E % 2 === 1 && (b ? g = b : m && (g = { ...a, fillColor: "#F9FAFB" }));
882
- let M = "";
883
- e && typeof e == "object" && e.content !== void 0 ? (M = String(e.content), e.colSpan && (u = e.colSpan), e.rowSpan && (h = e.rowSpan), e.style && (g = { ...g, ...e.style })) : M = String(e ?? "");
884
- let C = w[S];
885
- for (let k = 1; k < u; k++)
886
- S + k < w.length && (C += w[S + k]);
887
- let L = I;
888
- if (h > 1)
889
- for (let k = 1; k < h; k++)
890
- E + k < v.length && (L += v[E + k]);
891
- if (X(
892
- M,
893
- P,
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(
894
979
  T,
895
- C,
896
- L,
897
- g ?? {},
898
- _.align ?? "left",
980
+ _,
981
+ E,
982
+ B,
983
+ G,
984
+ F ?? {},
985
+ o.align ?? "left",
899
986
  !0
900
- ), h > 1) {
901
- A[S] = h - 1;
902
- for (let k = 1; k < u; k++)
903
- S + k < A.length && (A[S + k] = h - 1);
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);
904
991
  }
905
- P += C, S += u - 1;
992
+ _ += B, R += b - 1;
906
993
  }
907
- T += I;
994
+ E += D;
908
995
  }
909
- c.setCursor(O, T);
996
+ h.setCursor(z, E);
910
997
  })();
911
998
  });
912
- }, [c, n, t, r]), null;
913
- }, Tt = ({
999
+ }, [h, n, t, r]), null;
1000
+ }, yt = ({
914
1001
  children: n,
915
1002
  x: t,
916
1003
  y: r,
917
- maxWidth: i,
918
- spacingBelow: o = 2,
919
- ...f
1004
+ maxWidth: a,
1005
+ spacingBelow: i = 2,
1006
+ ...s
920
1007
  }) => {
921
- const s = $();
922
- return H.useEffect(() => {
923
- s.queueOperation(() => {
924
- const a = s.getCursor();
925
- let b = 0;
1008
+ const e = V();
1009
+ return $.useLayoutEffect(() => {
1010
+ e.queueOperation(() => {
1011
+ const f = e.getCursor();
1012
+ let u = 0;
926
1013
  const p = () => {
927
1014
  if (typeof t == "number" && typeof r == "number")
928
- s.textRaw(n, t, r, f, i, f.align);
1015
+ e.textRaw(n, t, r, s, a, s.align);
929
1016
  else {
930
- s.setCursor(a.x, a.y), b = s.paragraph(n, f, i);
931
- const l = s.getCursor();
932
- s.setCursor(l.x, l.y + o);
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);
933
1020
  }
934
1021
  };
935
- p(), f.showInAllPages && s.registerRecurringItem({
1022
+ p(), s.showInAllPages && e.registerRecurringItem({
936
1023
  draw: p,
937
- scope: f.scope ?? "all",
938
- y: a.y,
939
- height: b + o
1024
+ scope: s.scope ?? "all",
1025
+ y: f.y,
1026
+ height: u + i
940
1027
  });
941
1028
  });
942
1029
  }, [
943
- s,
1030
+ e,
944
1031
  n,
945
1032
  t,
946
1033
  r,
1034
+ a,
947
1035
  i,
948
- o,
949
- f.fontSize,
950
- f.align
1036
+ s.fontSize,
1037
+ s.align
951
1038
  ]), null;
952
1039
  }, mt = ({
953
1040
  viewState: n,
954
1041
  style: t,
955
1042
  pad: r,
956
- margin: i,
957
- w: o,
958
- h: f
1043
+ margin: a,
1044
+ w: i,
1045
+ h: s
959
1046
  }) => {
960
- const s = $();
961
- return H.useEffect(() => {
962
- s.queueOperation(() => {
963
- const a = n.start;
964
- if (!a) return;
965
- const b = s.getCursor(), p = Math.max(b.y - a.y - r.top, 0);
966
- let l = f ?? p + r.top + r.bottom;
967
- t.height && (l = t.height);
968
- let m = o ?? s.contentAreaWidth;
969
- typeof t.width == "number" && (m = t.width);
970
- const c = () => {
971
- (t.borderColor || t.fillColor || t.borderWidth) && s.box(a.x, a.y, m, l, t);
972
- };
973
- if (c(), t.showInAllPages && s.registerRecurringItem({
974
- draw: c,
975
- scope: t.scope ?? "all",
976
- y: a.y,
977
- height: l
978
- }), !n.isAbsolute) {
979
- const y = a.y + l + i.bottom;
980
- s.setCursor(a.x, y);
1047
+ const e = V();
1048
+ return $.useLayoutEffect(() => {
1049
+ e.queueOperation(() => {
1050
+ const f = n.start;
1051
+ 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);
1065
+ } 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
+ );
1074
+ }
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);
1082
+ }
981
1083
  }
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);
1088
+ };
1089
+ e.registerRecurringItem({
1090
+ draw: g,
1091
+ scope: t.scope ?? "all",
1092
+ y: f.y,
1093
+ height: t.height ?? 0
1094
+ });
1095
+ }
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();
982
1101
  });
983
- }, [s, t.showInAllPages, t.scope, o, f]), null;
1102
+ }, [e, t.showInAllPages, t.scope, i, s]), null;
984
1103
  };
985
1104
  function bt(n) {
986
1105
  return typeof n == "number" ? { top: n, right: n, bottom: n, left: n } : {
@@ -990,57 +1109,100 @@ function bt(n) {
990
1109
  left: n?.left ?? 0
991
1110
  };
992
1111
  }
993
- const Pt = ({
994
- style: n = {},
995
- children: t,
996
- x: r,
997
- y: i,
998
- w: o,
999
- h: f
1112
+ const wt = ({
1113
+ style: n,
1114
+ x: t,
1115
+ y: r,
1116
+ w: a,
1117
+ h: i,
1118
+ viewState: s
1000
1119
  }) => {
1001
- const s = $(), a = tt(n.padding), b = {
1002
- top: n.paddingTop ?? a.top,
1003
- right: n.paddingRight ?? a.right,
1004
- bottom: n.paddingBottom ?? a.bottom,
1005
- left: n.paddingLeft ?? a.left
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
1006
1125
  }, p = bt(n.margin), l = {
1007
1126
  top: n.marginTop ?? p.top,
1008
1127
  right: n.marginRight ?? p.right,
1009
1128
  bottom: n.marginBottom ?? p.bottom,
1010
1129
  left: n.marginLeft ?? p.left
1011
- }, m = H.useRef({}).current;
1012
- return H.useEffect(() => {
1013
- s.queueOperation(() => {
1014
- if (typeof r == "number" && typeof i == "number" && typeof o == "number" && typeof f == "number")
1015
- m.isAbsolute = !0, m.start = { x: r, y: i }, s.setCursor(r + b.left, i + b.top);
1016
- else {
1017
- m.isAbsolute = !1, l.top > 0 && s.moveCursor(0, l.top);
1018
- const c = s.getCursor();
1019
- m.start = { ...c }, s.setCursor(c.x + b.left, c.y + b.top);
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);
1137
+ } 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);
1020
1141
  }
1021
1142
  });
1022
- }, [s, r, i, o, f]), /* @__PURE__ */ U.jsxs(H.Fragment, { children: [
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 = ({
1154
+ style: n = {},
1155
+ children: t,
1156
+ x: r,
1157
+ y: a,
1158
+ w: i,
1159
+ h: s
1160
+ }) => {
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,
1176
+ {
1177
+ style: n,
1178
+ x: r,
1179
+ y: a,
1180
+ w: i,
1181
+ h: s,
1182
+ viewState: l
1183
+ }
1184
+ ),
1023
1185
  t,
1024
1186
  /* @__PURE__ */ U.jsx(
1025
1187
  mt,
1026
1188
  {
1027
- viewState: m,
1189
+ viewState: l,
1028
1190
  style: n,
1029
- pad: b,
1030
- margin: l,
1031
- w: o,
1032
- h: f
1191
+ pad: f,
1192
+ margin: p,
1193
+ w: i,
1194
+ h: s
1033
1195
  }
1034
1196
  )
1035
1197
  ] });
1036
1198
  };
1037
1199
  export {
1038
1200
  pt as PdfDocument,
1039
- St as PdfImage,
1040
- Rt as PdfList,
1041
- xt as PdfPreview,
1201
+ Rt as PdfImage,
1202
+ St as PdfList,
1203
+ Tt as PdfPreview,
1042
1204
  gt as PdfRenderer,
1043
- Ct as PdfTable,
1044
- Tt as PdfText,
1045
- Pt as PdfView
1205
+ Pt as PdfTable,
1206
+ yt as PdfText,
1207
+ Et as PdfView
1046
1208
  };