@antontranelis/money-printer 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { jsxs as f, jsx as l, Fragment as $ } from "react/jsx-runtime";
2
- import { create as he } from "zustand";
3
- import { persist as pe } from "zustand/middleware";
4
- import { useState as S, useCallback as C, useRef as L, useEffect as V } from "react";
5
- import me from "jspdf";
6
- const G = {
1
+ import { jsxs as m, jsx as l, Fragment as M } from "react/jsx-runtime";
2
+ import { create as fe } from "zustand";
3
+ import { persist as be } from "zustand/middleware";
4
+ import { useState as N, useCallback as C, useRef as $, useEffect as G } from "react";
5
+ import ye from "jspdf";
6
+ const V = {
7
7
  personalInfo: {
8
8
  name: "",
9
9
  email: "",
@@ -23,10 +23,10 @@ const G = {
23
23
  currentSide: "front",
24
24
  isEnhancing: !1,
25
25
  isExporting: !1
26
- }, y = he()(
27
- pe(
26
+ }, w = fe()(
27
+ be(
28
28
  (e) => ({
29
- ...G,
29
+ ...V,
30
30
  setPersonalInfo: (t) => e((a) => ({
31
31
  personalInfo: { ...a.personalInfo, ...t }
32
32
  })),
@@ -72,7 +72,7 @@ const G = {
72
72
  setHours: (t) => e((a) => ({
73
73
  voucherConfig: { ...a.voucherConfig, hours: t }
74
74
  })),
75
- reset: () => e(G)
75
+ reset: () => e(V)
76
76
  }),
77
77
  {
78
78
  name: "money-generator-storage",
@@ -82,7 +82,7 @@ const G = {
82
82
  })
83
83
  }
84
84
  )
85
- ), ue = {
85
+ ), we = {
86
86
  header: {
87
87
  title: "Money Generator",
88
88
  subtitle: "Erstelle deinen persönlichen Zeitgutschein"
@@ -129,7 +129,7 @@ const G = {
129
129
  bill: {
130
130
  descriptionText: "Für diesen Schein erhältst du {hours} {hourLabel} meiner Zeit oder ein gleichwertiges Dankeschön"
131
131
  }
132
- }, ge = {
132
+ }, ve = {
133
133
  header: {
134
134
  title: "Money Generator",
135
135
  subtitle: "Create your personal time voucher"
@@ -176,20 +176,20 @@ const G = {
176
176
  bill: {
177
177
  descriptionText: "This voucher entitles you to {hours} {hourLabel} of my time or an equivalent thank you"
178
178
  }
179
- }, fe = { de: ue, en: ge };
180
- function D(e) {
181
- return fe[e];
179
+ }, xe = { de: we, en: ve };
180
+ function z(e) {
181
+ return xe[e];
182
182
  }
183
183
  function J(e, t, a) {
184
184
  if (a && a.trim())
185
185
  return a;
186
- const n = D(e), r = t === 1 ? n.form.voucher.hourLabel : n.form.voucher.hoursLabel;
186
+ const n = z(e), r = t === 1 ? n.form.voucher.hourLabel : n.form.voucher.hoursLabel;
187
187
  return n.bill.descriptionText.replace("{hours}", t.toString()).replace("{hourLabel}", r);
188
188
  }
189
- function Oe() {
190
- const e = y((r) => r.voucherConfig.language), t = y((r) => r.personalInfo), a = y((r) => r.setPersonalInfo), n = D(e);
191
- return /* @__PURE__ */ f("div", { className: "space-y-4", children: [
192
- /* @__PURE__ */ f("div", { className: "form-control", children: [
189
+ function Ve() {
190
+ const e = w((r) => r.voucherConfig.language), t = w((r) => r.personalInfo), a = w((r) => r.setPersonalInfo), n = z(e);
191
+ return /* @__PURE__ */ m("div", { className: "space-y-4", children: [
192
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
193
193
  /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text font-medium", children: n.form.personalInfo.name }) }),
194
194
  /* @__PURE__ */ l(
195
195
  "input",
@@ -202,7 +202,7 @@ function Oe() {
202
202
  }
203
203
  )
204
204
  ] }),
205
- /* @__PURE__ */ f("div", { className: "form-control", children: [
205
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
206
206
  /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text font-medium", children: n.form.personalInfo.email }) }),
207
207
  /* @__PURE__ */ l(
208
208
  "input",
@@ -215,7 +215,7 @@ function Oe() {
215
215
  }
216
216
  )
217
217
  ] }),
218
- /* @__PURE__ */ f("div", { className: "form-control", children: [
218
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
219
219
  /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text font-medium", children: n.form.personalInfo.phone }) }),
220
220
  /* @__PURE__ */ l(
221
221
  "input",
@@ -230,7 +230,7 @@ function Oe() {
230
230
  ] })
231
231
  ] });
232
232
  }
233
- const K = {}, be = "https://api.stability.ai/v1/generation", ye = "https://api.stability.ai/v2beta/stable-image/edit/remove-background", Q = "stability_api_key", we = {
233
+ const j = {}, Ie = "https://api.stability.ai/v1/generation", ke = "https://api.stability.ai/v2beta/stable-image/edit/remove-background", Q = "stability_api_key", Ne = {
234
234
  vintage: "portrait in the style of vintage currency engraving, fine line work, crosshatching, sepia tones, detailed stippling, classic bank note portrait style",
235
235
  engraved: "portrait as detailed intaglio engraving, currency bill style, fine parallel lines, high contrast, official government portrait",
236
236
  currency: "portrait rendered as US dollar bill engraving, official currency portrait style, green tint, fine line engraving technique"
@@ -245,80 +245,80 @@ const K = {}, be = "https://api.stability.ai/v1/generation", ye = "https://api.s
245
245
  { width: 832, height: 1216 },
246
246
  { width: 896, height: 1152 }
247
247
  ];
248
- function ve(e, t) {
248
+ function Ee(e, t) {
249
249
  const a = e / t;
250
250
  let n = Z[0], r = 1 / 0;
251
- for (const i of Z) {
252
- const c = i.width / i.height, s = Math.abs(a - c);
253
- s < r && (r = s, n = i);
251
+ for (const s of Z) {
252
+ const d = s.width / s.height, o = Math.abs(a - d);
253
+ o < r && (r = o, n = s);
254
254
  }
255
255
  return n;
256
256
  }
257
- function xe(e) {
257
+ function Pe(e) {
258
258
  return new Promise((t, a) => {
259
259
  const n = new Image();
260
260
  n.onload = () => {
261
- const r = ve(n.width, n.height), i = document.createElement("canvas");
262
- i.width = r.width, i.height = r.height;
263
- const c = i.getContext("2d");
264
- if (!c) {
261
+ const r = Ee(n.width, n.height), s = document.createElement("canvas");
262
+ s.width = r.width, s.height = r.height;
263
+ const d = s.getContext("2d");
264
+ if (!d) {
265
265
  a(new Error("Failed to get canvas context"));
266
266
  return;
267
267
  }
268
- const s = n.width / n.height, o = r.width / r.height;
269
- let d = 0, p = 0, u = n.width, b = n.height;
270
- s > o ? (u = n.height * o, d = (n.width - u) / 2) : (b = n.width / o, p = (n.height - b) / 2), c.drawImage(n, d, p, u, b, 0, 0, r.width, r.height), t(i.toDataURL("image/png"));
268
+ const o = n.width / n.height, i = r.width / r.height;
269
+ let c = 0, u = 0, g = n.width, f = n.height;
270
+ o > i ? (g = n.height * i, c = (n.width - g) / 2) : (f = n.width / i, u = (n.height - f) / 2), d.drawImage(n, c, u, g, f, 0, 0, r.width, r.height), t(s.toDataURL("image/png"));
271
271
  }, n.onerror = () => a(new Error("Failed to load image")), n.src = e;
272
272
  });
273
273
  }
274
274
  function ee(e) {
275
- var c;
276
- const t = e.split(","), a = ((c = t[0].match(/:(.*?);/)) == null ? void 0 : c[1]) || "image/png", n = atob(t[1]), r = n.length, i = new Uint8Array(r);
277
- for (let s = 0; s < r; s++)
278
- i[s] = n.charCodeAt(s);
279
- return new Blob([i], { type: a });
275
+ var d;
276
+ const t = e.split(","), a = ((d = t[0].match(/:(.*?);/)) == null ? void 0 : d[1]) || "image/png", n = atob(t[1]), r = n.length, s = new Uint8Array(r);
277
+ for (let o = 0; o < r; o++)
278
+ s[o] = n.charCodeAt(o);
279
+ return new Blob([s], { type: a });
280
280
  }
281
- function Y() {
281
+ function q() {
282
282
  var t;
283
- const e = typeof import.meta < "u" && (K == null ? void 0 : K.VITE_STABILITY_API_KEY) || typeof process < "u" && ((t = process.env) == null ? void 0 : t.NEXT_PUBLIC_STABILITY_API_KEY);
283
+ const e = typeof import.meta < "u" && (j == null ? void 0 : j.VITE_STABILITY_API_KEY) || typeof process < "u" && ((t = process.env) == null ? void 0 : t.NEXT_PUBLIC_STABILITY_API_KEY);
284
284
  return e && e !== "your-api-key-here" ? e : typeof localStorage < "u" ? localStorage.getItem(Q) : null;
285
285
  }
286
- function ke(e) {
286
+ function Se(e) {
287
287
  localStorage.setItem(Q, e);
288
288
  }
289
- function Ie() {
290
- return Y() !== null;
289
+ function Ce() {
290
+ return q() !== null;
291
291
  }
292
- async function je(e) {
293
- const t = Y();
292
+ async function Ze(e) {
293
+ const t = q();
294
294
  if (!t)
295
295
  throw new Error("No Stability AI API key configured");
296
- const { imageDataUrl: a, style: n, strength: r = 0.35 } = e, i = await xe(a), c = ee(i), s = new FormData();
297
- s.append("init_image", c, "portrait.png"), s.append("init_image_mode", "IMAGE_STRENGTH"), s.append("image_strength", String(1 - r)), s.append("text_prompts[0][text]", we[n]), s.append("text_prompts[0][weight]", "1"), s.append("cfg_scale", "7"), s.append("samples", "1"), s.append("steps", "30");
298
- const d = await fetch(`${be}/stable-diffusion-xl-1024-v1-0/image-to-image`, {
296
+ const { imageDataUrl: a, style: n, strength: r = 0.35 } = e, s = await Pe(a), d = ee(s), o = new FormData();
297
+ o.append("init_image", d, "portrait.png"), o.append("init_image_mode", "IMAGE_STRENGTH"), o.append("image_strength", String(1 - r)), o.append("text_prompts[0][text]", Ne[n]), o.append("text_prompts[0][weight]", "1"), o.append("cfg_scale", "7"), o.append("samples", "1"), o.append("steps", "30");
298
+ const c = await fetch(`${Ie}/stable-diffusion-xl-1024-v1-0/image-to-image`, {
299
299
  method: "POST",
300
300
  headers: {
301
301
  Authorization: `Bearer ${t}`,
302
302
  Accept: "application/json"
303
303
  },
304
- body: s
304
+ body: o
305
305
  });
306
- if (!d.ok) {
307
- const u = await d.text();
308
- throw console.error("Stability AI error:", u), d.status === 401 ? new Error("Invalid API key") : d.status === 402 ? new Error("Insufficient credits") : d.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(`API error: ${d.status}`);
306
+ if (!c.ok) {
307
+ const g = await c.text();
308
+ throw console.error("Stability AI error:", g), c.status === 401 ? new Error("Invalid API key") : c.status === 402 ? new Error("Insufficient credits") : c.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(`API error: ${c.status}`);
309
309
  }
310
- const p = await d.json();
311
- if (!p.artifacts || p.artifacts.length === 0)
310
+ const u = await c.json();
311
+ if (!u.artifacts || u.artifacts.length === 0)
312
312
  throw new Error("No image generated");
313
- return `data:image/png;base64,${p.artifacts[0].base64}`;
313
+ return `data:image/png;base64,${u.artifacts[0].base64}`;
314
314
  }
315
- async function Ee(e) {
316
- const t = Y();
315
+ async function Ae(e) {
316
+ const t = q();
317
317
  if (!t)
318
318
  throw new Error("No Stability AI API key configured");
319
319
  const a = ee(e), n = new FormData();
320
320
  n.append("image", a, "image.png"), n.append("output_format", "png");
321
- const r = await fetch(ye, {
321
+ const r = await fetch(ke, {
322
322
  method: "POST",
323
323
  headers: {
324
324
  Authorization: `Bearer ${t}`,
@@ -327,63 +327,63 @@ async function Ee(e) {
327
327
  body: n
328
328
  });
329
329
  if (!r.ok) {
330
- const c = await r.text();
331
- throw console.error("Stability AI remove background error:", c), r.status === 401 ? new Error("Invalid API key") : r.status === 402 ? new Error("Insufficient credits") : r.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(`API error: ${r.status}`);
330
+ const d = await r.text();
331
+ throw console.error("Stability AI remove background error:", d), r.status === 401 ? new Error("Invalid API key") : r.status === 402 ? new Error("Insufficient credits") : r.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(`API error: ${r.status}`);
332
332
  }
333
- const i = await r.blob();
334
- return new Promise((c, s) => {
335
- const o = new FileReader();
336
- o.onload = () => c(o.result), o.onerror = () => s(new Error("Failed to read result")), o.readAsDataURL(i);
333
+ const s = await r.blob();
334
+ return new Promise((d, o) => {
335
+ const i = new FileReader();
336
+ i.onload = () => d(i.result), i.onerror = () => o(new Error("Failed to read result")), i.readAsDataURL(s);
337
337
  });
338
338
  }
339
- async function Pe(e) {
339
+ async function Te(e) {
340
340
  return new Promise((t, a) => {
341
341
  const n = new Image();
342
342
  n.onload = () => {
343
- const r = document.createElement("canvas"), i = r.getContext("2d");
344
- if (!i) {
343
+ const r = document.createElement("canvas"), s = r.getContext("2d");
344
+ if (!s) {
345
345
  a(new Error("Failed to get canvas context"));
346
346
  return;
347
347
  }
348
- r.width = n.width, r.height = n.height, i.drawImage(n, 0, 0);
349
- const c = i.getImageData(0, 0, r.width, r.height), s = c.data;
350
- for (let o = 0; o < s.length; o += 4) {
351
- const d = s[o], p = s[o + 1], u = s[o + 2];
352
- if (s[o + 3] === 0) continue;
353
- const g = 0.299 * d + 0.587 * p + 0.114 * u, h = 1.4;
354
- let v = 259 * (h * 255 + 255) / (255 * (259 - h * 255)) * (g - 128) + 128;
355
- v = Math.max(0, Math.min(255, v));
356
- const I = Math.min(255, v * 1.1 + 20), P = Math.min(255, v * 0.95 + 10), w = Math.min(255, v * 0.8);
357
- s[o] = I, s[o + 1] = P, s[o + 2] = w;
348
+ r.width = n.width, r.height = n.height, s.drawImage(n, 0, 0);
349
+ const d = s.getImageData(0, 0, r.width, r.height), o = d.data;
350
+ for (let i = 0; i < o.length; i += 4) {
351
+ const c = o[i], u = o[i + 1], g = o[i + 2];
352
+ if (o[i + 3] === 0) continue;
353
+ const b = 0.299 * c + 0.587 * u + 0.114 * g, h = 1.4;
354
+ let x = 259 * (h * 255 + 255) / (255 * (259 - h * 255)) * (b - 128) + 128;
355
+ x = Math.max(0, Math.min(255, x));
356
+ const v = Math.min(255, x * 1.1 + 20), S = Math.min(255, x * 0.95 + 10), y = Math.min(255, x * 0.8);
357
+ o[i] = v, o[i + 1] = S, o[i + 2] = y;
358
358
  }
359
- i.putImageData(c, 0, 0), t(r.toDataURL("image/png"));
359
+ s.putImageData(d, 0, 0), t(r.toDataURL("image/png"));
360
360
  }, n.onerror = () => a(new Error("Failed to load image")), n.src = e;
361
361
  });
362
362
  }
363
- function Ne() {
364
- const [e, t] = S(!1), [a, n] = S(!1), [r, i] = S(null), [c, s] = S(Ie()), o = C(() => i(null), []), d = C((b) => {
365
- ke(b), s(!0), i(null);
366
- }, []), p = C(
367
- async (b, g = "vintage") => {
368
- t(!0), i(null);
363
+ function Le() {
364
+ const [e, t] = N(!1), [a, n] = N(!1), [r, s] = N(null), [d, o] = N(Ce()), i = C(() => s(null), []), c = C((f) => {
365
+ Se(f), o(!0), s(null);
366
+ }, []), u = C(
367
+ async (f, b = "vintage") => {
368
+ t(!0), s(null);
369
369
  try {
370
- return await Pe(b);
370
+ return await Te(f);
371
371
  } catch (h) {
372
372
  const E = h instanceof Error ? h.message : "Enhancement failed";
373
- throw i(E), h;
373
+ throw s(E), h;
374
374
  } finally {
375
375
  t(!1);
376
376
  }
377
377
  },
378
378
  []
379
- ), u = C(
380
- async (b) => {
381
- n(!0), i(null);
379
+ ), g = C(
380
+ async (f) => {
381
+ n(!0), s(null);
382
382
  try {
383
- return await Ee(b);
384
- } catch (g) {
385
- const h = g instanceof Error ? g.message : "Background removal failed";
386
- throw i(h), g;
383
+ return await Ae(f);
384
+ } catch (b) {
385
+ const h = b instanceof Error ? b.message : "Background removal failed";
386
+ throw s(h), b;
387
387
  } finally {
388
388
  n(!1);
389
389
  }
@@ -391,22 +391,22 @@ function Ne() {
391
391
  []
392
392
  );
393
393
  return {
394
- enhance: p,
395
- removeBg: u,
394
+ enhance: u,
395
+ removeBg: g,
396
396
  isEnhancing: e,
397
397
  isRemovingBg: a,
398
398
  error: r,
399
- hasKey: c,
400
- setApiKey: d,
401
- clearError: o
399
+ hasKey: d,
400
+ setApiKey: c,
401
+ clearError: i
402
402
  };
403
403
  }
404
- function Se({ isOpen: e, onClose: t, onSubmit: a }) {
405
- const n = y((d) => d.voucherConfig.language), [r, i] = S("");
404
+ function De({ isOpen: e, onClose: t, onSubmit: a }) {
405
+ const n = w((c) => c.voucherConfig.language), [r, s] = N("");
406
406
  if (!e) return null;
407
- const c = (d) => {
408
- d.preventDefault(), r.trim() && (a(r.trim()), i(""), t());
409
- }, o = {
407
+ const d = (c) => {
408
+ c.preventDefault(), r.trim() && (a(r.trim()), s(""), t());
409
+ }, i = {
410
410
  de: {
411
411
  title: "Stability AI API Key",
412
412
  description: "Um die AI-Bildverbesserung zu nutzen, benötigst du einen Stability AI API Key. Du kannst ihn auf platform.stability.ai erhalten.",
@@ -424,104 +424,104 @@ function Se({ isOpen: e, onClose: t, onSubmit: a }) {
424
424
  hint: "The key is stored locally in your browser."
425
425
  }
426
426
  }[n];
427
- return /* @__PURE__ */ f("dialog", { className: "modal modal-open", children: [
428
- /* @__PURE__ */ f("div", { className: "modal-box", children: [
429
- /* @__PURE__ */ l("h3", { className: "font-bold text-lg", children: o.title }),
430
- /* @__PURE__ */ l("p", { className: "py-4 text-sm opacity-80", children: o.description }),
431
- /* @__PURE__ */ f("form", { onSubmit: c, children: [
432
- /* @__PURE__ */ f("div", { className: "form-control", children: [
427
+ return /* @__PURE__ */ m("dialog", { className: "modal modal-open", children: [
428
+ /* @__PURE__ */ m("div", { className: "modal-box", children: [
429
+ /* @__PURE__ */ l("h3", { className: "font-bold text-lg", children: i.title }),
430
+ /* @__PURE__ */ l("p", { className: "py-4 text-sm opacity-80", children: i.description }),
431
+ /* @__PURE__ */ m("form", { onSubmit: d, children: [
432
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
433
433
  /* @__PURE__ */ l(
434
434
  "input",
435
435
  {
436
436
  type: "password",
437
- placeholder: o.placeholder,
437
+ placeholder: i.placeholder,
438
438
  className: "input input-bordered w-full",
439
439
  value: r,
440
- onChange: (d) => i(d.target.value),
440
+ onChange: (c) => s(c.target.value),
441
441
  autoFocus: !0
442
442
  }
443
443
  ),
444
- /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text-alt", children: o.hint }) })
444
+ /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text-alt", children: i.hint }) })
445
445
  ] }),
446
- /* @__PURE__ */ f("div", { className: "modal-action", children: [
447
- /* @__PURE__ */ l("button", { type: "button", className: "btn btn-ghost", onClick: t, children: o.cancel }),
448
- /* @__PURE__ */ l("button", { type: "submit", className: "btn btn-primary", disabled: !r.trim(), children: o.submit })
446
+ /* @__PURE__ */ m("div", { className: "modal-action", children: [
447
+ /* @__PURE__ */ l("button", { type: "button", className: "btn btn-ghost", onClick: t, children: i.cancel }),
448
+ /* @__PURE__ */ l("button", { type: "submit", className: "btn btn-primary", disabled: !r.trim(), children: i.submit })
449
449
  ] })
450
450
  ] })
451
451
  ] }),
452
452
  /* @__PURE__ */ l("form", { method: "dialog", className: "modal-backdrop", children: /* @__PURE__ */ l("button", { onClick: t, children: "close" }) })
453
453
  ] });
454
454
  }
455
- function Ye() {
456
- const e = y((m) => m.voucherConfig.language), t = y((m) => m.portrait), a = y((m) => m.setPortrait), n = y((m) => m.setEnhancedPortrait), r = y((m) => m.toggleUseEnhanced), i = y((m) => m.setPortraitZoom), { enhance: c, removeBg: s, isEnhancing: o, isRemovingBg: d, error: p, hasKey: u, setApiKey: b } = Ne(), g = D(e), h = L(null), [E, v] = S(!1), [I, P] = S(!1), w = C(
457
- async (m) => {
458
- if (!m.type.startsWith("image/"))
455
+ function Xe() {
456
+ const e = w((p) => p.voucherConfig.language), t = w((p) => p.portrait), a = w((p) => p.setPortrait), n = w((p) => p.setPortraitZoom), { enhance: r, removeBg: s, isEnhancing: d, isRemovingBg: o, error: i, hasKey: c, setApiKey: u } = Le(), g = z(e), f = $(null), [b, h] = N(!1), [E, x] = N(!1), [v, S] = N(null), [y, k] = N(!1), [T, L] = N(!1), H = C(
457
+ async (p) => {
458
+ if (!p.type.startsWith("image/"))
459
459
  return;
460
- const x = new FileReader();
461
- x.onload = async (R) => {
462
- var q;
463
- const F = (q = R.target) == null ? void 0 : q.result;
464
- if (u)
465
- try {
466
- const W = await s(F);
467
- a(W);
468
- } catch (W) {
469
- console.error("Background removal failed, using original:", W), a(F);
470
- }
471
- else
472
- a(F);
473
- }, x.readAsDataURL(m);
460
+ const P = new FileReader();
461
+ P.onload = async (D) => {
462
+ var _;
463
+ const A = (_ = D.target) == null ? void 0 : _.result;
464
+ S(A), a(A), k(!1), L(!1);
465
+ }, P.readAsDataURL(p);
474
466
  },
475
- [a, u, s]
476
- ), N = C(
477
- (m) => {
478
- m.preventDefault(), v(!1);
479
- const x = m.dataTransfer.files[0];
480
- x && w(x);
467
+ [a]
468
+ ), W = C(
469
+ (p) => {
470
+ p.preventDefault(), h(!1);
471
+ const P = p.dataTransfer.files[0];
472
+ P && H(P);
481
473
  },
482
- [w]
483
- ), _ = C((m) => {
484
- m.preventDefault(), v(!0);
485
- }, []), B = C((m) => {
486
- m.preventDefault(), v(!1);
487
- }, []), U = () => {
488
- var m;
489
- (m = h.current) == null || m.click();
490
- }, H = (m) => {
491
- var R;
492
- const x = (R = m.target.files) == null ? void 0 : R[0];
493
- x && w(x);
494
- }, se = async () => {
495
- if (t.original) {
496
- if (!u) {
497
- P(!0);
498
- return;
499
- }
474
+ [H]
475
+ ), se = C((p) => {
476
+ p.preventDefault(), h(!0);
477
+ }, []), le = C((p) => {
478
+ p.preventDefault(), h(!1);
479
+ }, []), ce = () => {
480
+ var p;
481
+ (p = f.current) == null || p.click();
482
+ }, de = (p) => {
483
+ var D;
484
+ const P = (D = p.target.files) == null ? void 0 : D[0];
485
+ P && H(P);
486
+ }, K = C(async (p, P, D) => {
487
+ let A = p;
488
+ if (P && c)
500
489
  try {
501
- const m = await c(t.original, "vintage");
502
- n(m);
503
- } catch (m) {
504
- console.error("Enhancement failed:", m);
490
+ A = await s(A);
491
+ } catch (_) {
492
+ console.error("Background removal failed:", _);
505
493
  }
506
- }
507
- }, le = async (m) => {
508
- if (b(m), t.original)
494
+ if (D)
509
495
  try {
510
- const x = await c(t.original, "vintage");
511
- n(x);
512
- } catch (x) {
513
- console.error("Enhancement failed:", x);
496
+ A = await r(A, "vintage");
497
+ } catch (_) {
498
+ console.error("Enhancement failed:", _);
514
499
  }
515
- }, ce = () => {
516
- a(null);
517
- }, de = t.useEnhanced && t.enhanced ? t.enhanced : t.original;
518
- return /* @__PURE__ */ f("div", { className: "space-y-4", children: [
519
- t.original ? /* @__PURE__ */ f("div", { className: "space-y-4", children: [
520
- /* @__PURE__ */ l("div", { className: "flex justify-center", children: /* @__PURE__ */ f("div", { className: "relative", children: [
500
+ a(A);
501
+ }, [c, s, r, a]), he = async () => {
502
+ if (!v) return;
503
+ if (!y && !c) {
504
+ x(!0);
505
+ return;
506
+ }
507
+ const p = !y;
508
+ k(p), await K(v, p, T);
509
+ }, pe = async () => {
510
+ if (!v) return;
511
+ const p = !T;
512
+ L(p), await K(v, y, p);
513
+ }, me = async (p) => {
514
+ u(p), v && (k(!0), await K(v, !0, T));
515
+ }, ue = () => {
516
+ a(null), S(null), k(!1), L(!1);
517
+ }, ge = t.original;
518
+ return /* @__PURE__ */ m("div", { className: "space-y-4", children: [
519
+ t.original ? /* @__PURE__ */ m("div", { className: "space-y-4", children: [
520
+ /* @__PURE__ */ l("div", { className: "flex justify-center", children: /* @__PURE__ */ m("div", { className: "relative", children: [
521
521
  /* @__PURE__ */ l("div", { className: "w-32 h-32 rounded-full overflow-hidden border-4 border-currency-gold shadow-lg", children: /* @__PURE__ */ l(
522
522
  "img",
523
523
  {
524
- src: de || "",
524
+ src: ge || "",
525
525
  alt: "Portrait",
526
526
  className: "w-full h-full object-cover",
527
527
  style: { transform: `scale(${t.zoom})` }
@@ -531,7 +531,7 @@ function Ye() {
531
531
  "button",
532
532
  {
533
533
  className: "btn btn-circle btn-xs btn-error absolute -top-1 -right-1",
534
- onClick: ce,
534
+ onClick: ue,
535
535
  children: /* @__PURE__ */ l(
536
536
  "svg",
537
537
  {
@@ -554,10 +554,10 @@ function Ye() {
554
554
  }
555
555
  )
556
556
  ] }) }),
557
- /* @__PURE__ */ f("div", { className: "form-control", children: [
558
- /* @__PURE__ */ f("label", { className: "label", children: [
557
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
558
+ /* @__PURE__ */ m("label", { className: "label", children: [
559
559
  /* @__PURE__ */ l("span", { className: "label-text", children: g.form.portrait.zoom }),
560
- /* @__PURE__ */ f("span", { className: "label-text-alt", children: [
560
+ /* @__PURE__ */ m("span", { className: "label-text-alt", children: [
561
561
  Math.round(t.zoom * 100),
562
562
  "%"
563
563
  ] })
@@ -570,85 +570,75 @@ function Ye() {
570
570
  max: "2",
571
571
  step: "0.05",
572
572
  value: t.zoom,
573
- onChange: (m) => i(parseFloat(m.target.value)),
573
+ onChange: (p) => n(parseFloat(p.target.value)),
574
574
  className: "range range-primary range-sm"
575
575
  }
576
576
  )
577
577
  ] }),
578
- u && /* @__PURE__ */ f("div", { className: "flex flex-col gap-2", children: [
579
- /* @__PURE__ */ l(
580
- "button",
581
- {
582
- className: `btn btn-secondary ${o ? "loading" : ""}`,
583
- onClick: se,
584
- disabled: o,
585
- children: o ? /* @__PURE__ */ f($, { children: [
586
- /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-sm" }),
587
- g.form.portrait.enhancing
588
- ] }) : /* @__PURE__ */ f($, { children: [
589
- /* @__PURE__ */ l(
590
- "svg",
591
- {
592
- xmlns: "http://www.w3.org/2000/svg",
593
- className: "h-5 w-5 mr-1",
594
- fill: "none",
595
- viewBox: "0 0 24 24",
596
- stroke: "currentColor",
597
- children: /* @__PURE__ */ l(
598
- "path",
599
- {
600
- strokeLinecap: "round",
601
- strokeLinejoin: "round",
602
- strokeWidth: 2,
603
- d: "M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"
604
- }
605
- )
606
- }
607
- ),
608
- g.form.portrait.enhance
609
- ] })
610
- }
611
- ),
612
- p && /* @__PURE__ */ f("div", { className: "alert alert-warning text-sm py-2", children: [
613
- /* @__PURE__ */ l("svg", { xmlns: "http://www.w3.org/2000/svg", className: "stroke-current shrink-0 h-5 w-5", fill: "none", viewBox: "0 0 24 24", children: /* @__PURE__ */ l("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
614
- /* @__PURE__ */ l("span", { children: p })
615
- ] }),
616
- t.enhanced && /* @__PURE__ */ l("div", { className: "form-control", children: /* @__PURE__ */ f("label", { className: "label cursor-pointer justify-start gap-3", children: [
578
+ /* @__PURE__ */ m("div", { className: "flex flex-col gap-3", children: [
579
+ /* @__PURE__ */ l("div", { className: "form-control", children: /* @__PURE__ */ m("label", { className: "label cursor-pointer justify-start gap-3", children: [
580
+ /* @__PURE__ */ l(
581
+ "input",
582
+ {
583
+ type: "checkbox",
584
+ className: `toggle toggle-primary ${o ? "opacity-50" : ""}`,
585
+ checked: y,
586
+ onChange: he,
587
+ disabled: o
588
+ }
589
+ ),
590
+ /* @__PURE__ */ m("span", { className: "label-text flex items-center gap-2", children: [
591
+ o ? /* @__PURE__ */ m(M, { children: [
592
+ /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-xs" }),
593
+ e === "de" ? "Hintergrund wird entfernt..." : "Removing background..."
594
+ ] }) : e === "de" ? "Hintergrund entfernen" : "Remove background",
595
+ !c && /* @__PURE__ */ l("span", { className: "badge badge-sm badge-outline", children: "API" })
596
+ ] })
597
+ ] }) }),
598
+ /* @__PURE__ */ l("div", { className: "form-control", children: /* @__PURE__ */ m("label", { className: "label cursor-pointer justify-start gap-3", children: [
617
599
  /* @__PURE__ */ l(
618
600
  "input",
619
601
  {
620
602
  type: "checkbox",
621
- className: "toggle toggle-primary",
622
- checked: t.useEnhanced,
623
- onChange: r
603
+ className: `toggle toggle-secondary ${d ? "opacity-50" : ""}`,
604
+ checked: T,
605
+ onChange: pe,
606
+ disabled: d
624
607
  }
625
608
  ),
626
- /* @__PURE__ */ l("span", { className: "label-text", children: t.useEnhanced ? g.form.portrait.useEnhanced : g.form.portrait.useOriginal })
627
- ] }) })
609
+ /* @__PURE__ */ l("span", { className: "label-text flex items-center gap-2", children: d ? /* @__PURE__ */ m(M, { children: [
610
+ /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-xs" }),
611
+ e === "de" ? "Gravur-Effekt wird angewendet..." : "Applying engraving effect..."
612
+ ] }) : e === "de" ? "Gravur-Effekt" : "Engraving effect" })
613
+ ] }) }),
614
+ i && /* @__PURE__ */ m("div", { className: "alert alert-warning text-sm py-2", children: [
615
+ /* @__PURE__ */ l("svg", { xmlns: "http://www.w3.org/2000/svg", className: "stroke-current shrink-0 h-5 w-5", fill: "none", viewBox: "0 0 24 24", children: /* @__PURE__ */ l("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
616
+ /* @__PURE__ */ l("span", { children: i })
617
+ ] })
628
618
  ] })
629
- ] }) : /* @__PURE__ */ f(
619
+ ] }) : /* @__PURE__ */ m(
630
620
  "div",
631
621
  {
632
- className: `border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${d ? "border-primary bg-primary/10 pointer-events-none" : E ? "border-primary bg-primary/10" : "border-base-300 hover:border-primary hover:bg-base-200"}`,
633
- onDrop: N,
634
- onDragOver: _,
635
- onDragLeave: B,
636
- onClick: U,
622
+ className: `border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o ? "border-primary bg-primary/10 pointer-events-none" : b ? "border-primary bg-primary/10" : "border-base-300 hover:border-primary hover:bg-base-200"}`,
623
+ onDrop: W,
624
+ onDragOver: se,
625
+ onDragLeave: le,
626
+ onClick: ce,
637
627
  children: [
638
628
  /* @__PURE__ */ l(
639
629
  "input",
640
630
  {
641
- ref: h,
631
+ ref: f,
642
632
  type: "file",
643
633
  accept: "image/*",
644
634
  className: "hidden",
645
- onChange: H
635
+ onChange: de
646
636
  }
647
637
  ),
648
- d ? /* @__PURE__ */ f("div", { className: "flex flex-col items-center gap-2", children: [
638
+ o ? /* @__PURE__ */ m("div", { className: "flex flex-col items-center gap-2", children: [
649
639
  /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-lg text-primary" }),
650
640
  /* @__PURE__ */ l("p", { className: "font-medium", children: e === "de" ? "Hintergrund wird entfernt..." : "Removing background..." })
651
- ] }) : /* @__PURE__ */ f("div", { className: "flex flex-col items-center gap-2", children: [
641
+ ] }) : /* @__PURE__ */ m("div", { className: "flex flex-col items-center gap-2", children: [
652
642
  /* @__PURE__ */ l(
653
643
  "svg",
654
644
  {
@@ -675,60 +665,60 @@ function Ye() {
675
665
  }
676
666
  ),
677
667
  /* @__PURE__ */ l(
678
- Se,
668
+ De,
679
669
  {
680
- isOpen: I,
681
- onClose: () => P(!1),
682
- onSubmit: le
670
+ isOpen: E,
671
+ onClose: () => x(!1),
672
+ onSubmit: me
683
673
  }
684
674
  )
685
675
  ] });
686
676
  }
687
- function qe() {
677
+ function Je() {
688
678
  return null;
689
679
  }
690
- const k = typeof import.meta < "u" && "/" || "/", Ce = {
680
+ const I = typeof import.meta < "u" && "/" || "/", _e = {
691
681
  en: {
692
682
  1: {
693
- front: `${k}templates/front_ldpi_en.png`,
694
- back: `${k}templates/back_ldpi_en.png`,
683
+ front: `${I}templates/front_ldpi_en.png`,
684
+ back: `${I}templates/back_ldpi_en.png`,
695
685
  width: 1536,
696
686
  height: 1024
697
687
  },
698
688
  5: {
699
- front: `${k}templates/front_ldpi_en.png`,
700
- back: `${k}templates/back_ldpi_en.png`,
689
+ front: `${I}templates/front_ldpi_en.png`,
690
+ back: `${I}templates/back_ldpi_en.png`,
701
691
  width: 1536,
702
692
  height: 1024
703
693
  },
704
694
  10: {
705
- front: `${k}templates/front_ldpi_en.png`,
706
- back: `${k}templates/back_ldpi_en.png`,
695
+ front: `${I}templates/front_ldpi_en.png`,
696
+ back: `${I}templates/back_ldpi_en.png`,
707
697
  width: 1536,
708
698
  height: 1024
709
699
  }
710
700
  },
711
701
  de: {
712
702
  1: {
713
- front: `${k}templates/front_hdpi_de.webp`,
714
- back: `${k}templates/back_hdpi_de.webp`,
703
+ front: `${I}templates/front_hdpi_de.webp`,
704
+ back: `${I}templates/back_hdpi_de.webp`,
715
705
  width: 6144,
716
706
  height: 3200
717
707
  },
718
708
  5: {
719
- front: `${k}templates/front_hdpi_de.webp`,
720
- back: `${k}templates/back_hdpi_de.webp`,
709
+ front: `${I}templates/front_hdpi_de.webp`,
710
+ back: `${I}templates/back_hdpi_de.webp`,
721
711
  width: 6144,
722
712
  height: 3200
723
713
  },
724
714
  10: {
725
- front: `${k}templates/front_hdpi_de.webp`,
726
- back: `${k}templates/back_hdpi_de.webp`,
715
+ front: `${I}templates/front_hdpi_de.webp`,
716
+ back: `${I}templates/back_hdpi_de.webp`,
727
717
  width: 6144,
728
718
  height: 3200
729
719
  }
730
720
  }
731
- }, T = {
721
+ }, B = {
732
722
  front: {
733
723
  portrait: {
734
724
  x: 768,
@@ -774,7 +764,7 @@ const k = typeof import.meta < "u" && "/" || "/", Ce = {
774
764
  align: "center"
775
765
  }
776
766
  }
777
- }, A = {
767
+ }, R = {
778
768
  front: {
779
769
  portrait: {
780
770
  x: 3074,
@@ -822,13 +812,13 @@ const k = typeof import.meta < "u" && "/" || "/", Ce = {
822
812
  }
823
813
  };
824
814
  function te(e) {
825
- return e === "de" ? A : T;
815
+ return e === "de" ? R : B;
826
816
  }
827
817
  function ne(e, t) {
828
- return Ce[e][t];
818
+ return _e[e][t];
829
819
  }
830
820
  const O = /* @__PURE__ */ new Map();
831
- async function j(e) {
821
+ async function Y(e) {
832
822
  return O.has(e) ? O.get(e) : new Promise((t, a) => {
833
823
  const n = new Image();
834
824
  n.crossOrigin = "anonymous", n.onload = () => {
@@ -839,121 +829,121 @@ async function j(e) {
839
829
  function ae(e, t, a, n) {
840
830
  e.drawImage(t, 0, 0, a, n);
841
831
  }
842
- function Te(e, t, a, n, r, i, c = 1) {
843
- e.save(), e.beginPath(), e.ellipse(a, n, r, i, 0, 0, Math.PI * 2), e.closePath(), e.clip();
844
- const s = t.width / t.height, o = r / i, d = r * 2, p = i * 2;
845
- let u, b;
846
- s > o ? (b = p, u = p * s) : (u = d, b = d / s), u *= c, b *= c;
847
- const g = a - u / 2, h = n - b / 2;
848
- e.drawImage(t, g, h, u, b), e.restore();
832
+ function Be(e, t, a, n, r, s, d = 1) {
833
+ e.save(), e.beginPath(), e.ellipse(a, n, r, s, 0, 0, Math.PI * 2), e.closePath(), e.clip();
834
+ const o = t.width / t.height, i = r / s, c = r * 2, u = s * 2;
835
+ let g, f;
836
+ o > i ? (f = u, g = u * o) : (g = c, f = c / o), g *= d, f *= d;
837
+ const b = a - g / 2, h = n - f / 2;
838
+ e.drawImage(t, b, h, g, f), e.restore();
849
839
  }
850
840
  function re(e, t, a, n = "#2a3a2a") {
851
841
  e.save(), e.font = `${a.fontSize}px "Times New Roman", serif`, e.textAlign = a.align || "center", e.textBaseline = "middle", e.fillStyle = n, a.maxWidth ? e.fillText(t, a.x, a.y, a.maxWidth) : e.fillText(t, a.x, a.y), e.restore();
852
842
  }
853
- function Ae(e, t, a, n = "#2a3a2a") {
843
+ function Re(e, t, a, n = "#2a3a2a") {
854
844
  e.save(), e.font = `${a.fontSize}px "Times New Roman", serif`, e.textAlign = a.align || "center", e.textBaseline = "top", e.fillStyle = n;
855
- const r = a.maxWidth || 400, i = a.lineHeight || a.fontSize * 1.4, c = t.split(" "), s = [];
856
- let o = "";
857
- for (const u of c) {
858
- const b = o ? `${o} ${u}` : u;
859
- e.measureText(b).width > r && o ? (s.push(o), o = u) : o = b;
845
+ const r = a.maxWidth || 400, s = a.lineHeight || a.fontSize * 1.4, d = t.split(" "), o = [];
846
+ let i = "";
847
+ for (const g of d) {
848
+ const f = i ? `${i} ${g}` : g;
849
+ e.measureText(f).width > r && i ? (o.push(i), i = g) : i = f;
860
850
  }
861
- o && s.push(o);
862
- const d = s.length * i;
863
- let p = a.y - d / 2;
864
- for (const u of s)
865
- e.fillText(u, a.x, p), p += i;
851
+ i && o.push(i);
852
+ const c = o.length * s;
853
+ let u = a.y - c / 2;
854
+ for (const g of o)
855
+ e.fillText(g, a.x, u), u += s;
866
856
  e.restore();
867
857
  }
868
- function Le(e, t, a, n, r, i = "#2a3a2a") {
869
- e.save(), e.font = `${r.fontSize}px "Times New Roman", serif`, e.textAlign = r.align || "center", e.textBaseline = "middle", e.fillStyle = i;
870
- const c = r.lineHeight || r.fontSize * 1.8, s = [t, a, n].filter(Boolean), o = (s.length - 1) * c;
871
- let d = r.y - o / 2;
872
- for (const p of s)
873
- p && (e.fillText(p, r.x, d), d += c);
858
+ function $e(e, t, a, n, r, s = "#2a3a2a") {
859
+ e.save(), e.font = `${r.fontSize}px "Times New Roman", serif`, e.textAlign = r.align || "center", e.textBaseline = "middle", e.fillStyle = s;
860
+ const d = r.lineHeight || r.fontSize * 1.8, o = [t, a, n].filter(Boolean), i = (o.length - 1) * d;
861
+ let c = r.y - i / 2;
862
+ for (const u of o)
863
+ u && (e.fillText(u, r.x, c), c += d);
874
864
  e.restore();
875
865
  }
876
- async function oe(e, t, a, n, r, i, c, s = 1) {
877
- const o = e.getContext("2d");
878
- if (!o) return;
879
- e.width = i, e.height = c, o.clearRect(0, 0, i, c);
880
- const d = await j(t);
881
- if (ae(o, d, i, c), a)
866
+ async function oe(e, t, a, n, r, s, d, o = 1) {
867
+ const i = e.getContext("2d");
868
+ if (!i) return;
869
+ e.width = s, e.height = d, i.clearRect(0, 0, s, d);
870
+ const c = await Y(t);
871
+ if (ae(i, c, s, d), a)
882
872
  try {
883
- const p = await j(a);
884
- Te(
885
- o,
886
- p,
873
+ const u = await Y(a);
874
+ Be(
875
+ i,
876
+ u,
887
877
  r.portrait.x,
888
878
  r.portrait.y,
889
879
  r.portrait.radiusX,
890
880
  r.portrait.radiusY,
891
- s
881
+ o
892
882
  );
893
- } catch (p) {
894
- console.error("Failed to load portrait:", p);
883
+ } catch (u) {
884
+ console.error("Failed to load portrait:", u);
895
885
  }
896
- n && re(o, n, r.namePlate);
886
+ n && re(i, n, r.namePlate);
897
887
  }
898
- async function ie(e, t, a, n, r, i, c, s, o) {
899
- const d = e.getContext("2d");
900
- if (!d) return;
901
- e.width = s, e.height = o, d.clearRect(0, 0, s, o);
902
- const p = await j(t);
903
- ae(d, p, s, o), c.contactInfo && (a || n || r) && Le(d, a, n, r, c.contactInfo), c.description && i && Ae(d, i, c.description), a && re(d, a, c.namePlate);
888
+ async function ie(e, t, a, n, r, s, d, o, i) {
889
+ const c = e.getContext("2d");
890
+ if (!c) return;
891
+ e.width = o, e.height = i, c.clearRect(0, 0, o, i);
892
+ const u = await Y(t);
893
+ ae(c, u, o, i), d.contactInfo && (a || n || r) && $e(c, a, n, r, d.contactInfo), d.description && s && Re(c, s, d.description), a && re(c, a, d.namePlate);
904
894
  }
905
- function Ve() {
906
- const e = y((w) => w.voucherConfig.language), t = y((w) => w.voucherConfig.hours), a = y((w) => w.voucherConfig.description), n = y((w) => w.personalInfo), r = y((w) => w.portrait), i = y((w) => w.currentSide), c = y((w) => w.flipSide), s = D(e), o = L(null), d = L(null), p = L(null), [u, b] = S(!1), g = ne(e, t), h = te(e), E = r.useEnhanced && r.enhanced ? r.enhanced : r.original, v = J(e, t, a);
907
- V(() => {
908
- o.current && oe(
909
- o.current,
910
- g.front,
895
+ function Qe() {
896
+ const e = w((y) => y.voucherConfig.language), t = w((y) => y.voucherConfig.hours), a = w((y) => y.voucherConfig.description), n = w((y) => y.personalInfo), r = w((y) => y.portrait), s = w((y) => y.currentSide), d = w((y) => y.flipSide), o = z(e), i = $(null), c = $(null), u = $(null), [g, f] = N(!1), b = ne(e, t), h = te(e), E = r.useEnhanced && r.enhanced ? r.enhanced : r.original, x = J(e, t, a);
897
+ G(() => {
898
+ i.current && oe(
899
+ i.current,
900
+ b.front,
911
901
  E,
912
902
  n.name,
913
903
  h.front,
914
- g.width,
915
- g.height,
904
+ b.width,
905
+ b.height,
916
906
  r.zoom
917
907
  );
918
- }, [g, E, n.name, h, r.zoom]), V(() => {
919
- d.current && ie(
920
- d.current,
921
- g.back,
908
+ }, [b, E, n.name, h, r.zoom]), G(() => {
909
+ c.current && ie(
910
+ c.current,
911
+ b.back,
922
912
  n.name,
923
913
  n.email,
924
914
  n.phone,
925
- v,
915
+ x,
926
916
  h.back,
927
- g.width,
928
- g.height
917
+ b.width,
918
+ b.height
929
919
  );
930
- }, [g, n, v, h]);
931
- const I = () => {
932
- b(!0), setTimeout(() => {
933
- c(), b(!1);
920
+ }, [b, n, x, h]);
921
+ const v = () => {
922
+ f(!0), setTimeout(() => {
923
+ d(), f(!1);
934
924
  }, 150);
935
- }, P = g.width / g.height;
936
- return /* @__PURE__ */ f("div", { className: "space-y-4", children: [
937
- /* @__PURE__ */ f("div", { className: "flex justify-between items-center", children: [
938
- /* @__PURE__ */ f("div", { className: "tabs tabs-boxed bg-base-200", children: [
925
+ }, S = b.width / b.height;
926
+ return /* @__PURE__ */ m("div", { className: "space-y-4", children: [
927
+ /* @__PURE__ */ m("div", { className: "flex justify-between items-center", children: [
928
+ /* @__PURE__ */ m("div", { className: "tabs tabs-boxed bg-base-200", children: [
939
929
  /* @__PURE__ */ l(
940
930
  "button",
941
931
  {
942
- className: `tab ${i === "front" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
943
- onClick: () => i !== "front" && I(),
944
- children: s.preview.front
932
+ className: `tab ${s === "front" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
933
+ onClick: () => s !== "front" && v(),
934
+ children: o.preview.front
945
935
  }
946
936
  ),
947
937
  /* @__PURE__ */ l(
948
938
  "button",
949
939
  {
950
- className: `tab ${i === "back" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
951
- onClick: () => i !== "back" && I(),
952
- children: s.preview.back
940
+ className: `tab ${s === "back" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
941
+ onClick: () => s !== "back" && v(),
942
+ children: o.preview.back
953
943
  }
954
944
  )
955
945
  ] }),
956
- /* @__PURE__ */ f("button", { className: "btn btn-ghost btn-sm", onClick: I, children: [
946
+ /* @__PURE__ */ m("button", { className: "btn btn-ghost btn-sm", onClick: v, children: [
957
947
  /* @__PURE__ */ l(
958
948
  "svg",
959
949
  {
@@ -973,28 +963,28 @@ function Ve() {
973
963
  )
974
964
  }
975
965
  ),
976
- s.preview.flip
966
+ o.preview.flip
977
967
  ] })
978
968
  ] }),
979
- /* @__PURE__ */ f(
969
+ /* @__PURE__ */ m(
980
970
  "div",
981
971
  {
982
- ref: p,
972
+ ref: u,
983
973
  className: "relative w-full overflow-hidden shadow-lg",
984
- style: { aspectRatio: P },
974
+ style: { aspectRatio: S },
985
975
  children: [
986
976
  /* @__PURE__ */ l(
987
977
  "canvas",
988
978
  {
989
- ref: o,
990
- className: `absolute inset-0 w-full h-full transition-all duration-300 ${i === "front" ? u ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
979
+ ref: i,
980
+ className: `absolute inset-0 w-full h-full transition-all duration-300 ${s === "front" ? g ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
991
981
  }
992
982
  ),
993
983
  /* @__PURE__ */ l(
994
984
  "canvas",
995
985
  {
996
- ref: d,
997
- className: `absolute inset-0 w-full h-full transition-all duration-300 ${i === "back" ? u ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
986
+ ref: c,
987
+ className: `absolute inset-0 w-full h-full transition-all duration-300 ${s === "back" ? g ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
998
988
  }
999
989
  )
1000
990
  ]
@@ -1002,85 +992,85 @@ function Ve() {
1002
992
  )
1003
993
  ] });
1004
994
  }
1005
- function Ge() {
1006
- const e = L(null), t = L(null);
995
+ function et() {
996
+ const e = $(null), t = $(null);
1007
997
  return { frontCanvasRef: e, backCanvasRef: t };
1008
998
  }
1009
- async function De(e) {
999
+ async function ze(e) {
1010
1000
  const {
1011
1001
  frontTemplateSrc: t,
1012
1002
  backTemplateSrc: a,
1013
1003
  templateWidth: n,
1014
1004
  templateHeight: r,
1015
- layout: i,
1016
- portrait: c,
1017
- portraitZoom: s = 1,
1018
- name: o,
1019
- email: d,
1020
- phone: p,
1021
- description: u
1022
- } = e, b = document.createElement("canvas"), g = document.createElement("canvas");
1005
+ layout: s,
1006
+ portrait: d,
1007
+ portraitZoom: o = 1,
1008
+ name: i,
1009
+ email: c,
1010
+ phone: u,
1011
+ description: g
1012
+ } = e, f = document.createElement("canvas"), b = document.createElement("canvas");
1023
1013
  await Promise.all([
1024
- oe(b, t, c, o, i.front, n, r, s),
1025
- ie(g, a, o, d, p, u, i.back, n, r)
1014
+ oe(f, t, d, i, s.front, n, r, o),
1015
+ ie(b, a, i, c, u, g, s.back, n, r)
1026
1016
  ]);
1027
- const h = new me({
1017
+ const h = new ye({
1028
1018
  orientation: "landscape",
1029
1019
  unit: "mm",
1030
1020
  format: "a4"
1031
- }), E = 297, v = 210, I = 10, P = n / r;
1032
- let w = E - I * 2, N = w / P;
1033
- N > v - I * 2 && (N = v - I * 2, w = N * P);
1034
- const _ = (E - w) / 2, B = (v - N) / 2, U = b.toDataURL("image/jpeg", 0.95);
1035
- h.addImage(U, "JPEG", _, B, w, N), h.addPage();
1036
- const H = g.toDataURL("image/jpeg", 0.95);
1037
- return h.addImage(H, "JPEG", _, B, w, N), h.output("blob");
1021
+ }), E = 297, x = 210, v = 10, S = n / r;
1022
+ let y = E - v * 2, k = y / S;
1023
+ k > x - v * 2 && (k = x - v * 2, y = k * S);
1024
+ const T = (E - y) / 2, L = (x - k) / 2, H = f.toDataURL("image/jpeg", 0.95);
1025
+ h.addImage(H, "JPEG", T, L, y, k), h.addPage();
1026
+ const W = b.toDataURL("image/jpeg", 0.95);
1027
+ return h.addImage(W, "JPEG", T, L, y, k), h.output("blob");
1038
1028
  }
1039
- function _e(e, t) {
1029
+ function He(e, t) {
1040
1030
  const a = URL.createObjectURL(e), n = document.createElement("a");
1041
1031
  n.href = a, n.download = t, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(a);
1042
1032
  }
1043
- async function Be(e) {
1044
- const t = await De(e);
1045
- _e(t, e.filename);
1033
+ async function Me(e) {
1034
+ const t = await ze(e);
1035
+ He(t, e.filename);
1046
1036
  }
1047
- function Ze() {
1048
- const e = y((h) => h.voucherConfig.language), t = y((h) => h.voucherConfig.hours), a = y((h) => h.voucherConfig.description), n = y((h) => h.personalInfo), r = y((h) => h.portrait), i = y((h) => h.isExporting), c = y((h) => h.setIsExporting), s = D(e), o = ne(e, t), d = te(e), p = r.useEnhanced && r.enhanced ? r.enhanced : r.original, u = J(e, t, a), b = n.name.trim().length > 0 && n.email.trim().length > 0 && n.phone.trim().length > 0 && r.original !== null;
1037
+ function tt() {
1038
+ const e = w((h) => h.voucherConfig.language), t = w((h) => h.voucherConfig.hours), a = w((h) => h.voucherConfig.description), n = w((h) => h.personalInfo), r = w((h) => h.portrait), s = w((h) => h.isExporting), d = w((h) => h.setIsExporting), o = z(e), i = ne(e, t), c = te(e), u = r.useEnhanced && r.enhanced ? r.enhanced : r.original, g = J(e, t, a), f = n.name.trim().length > 0 && n.email.trim().length > 0 && n.phone.trim().length > 0 && r.original !== null;
1049
1039
  return /* @__PURE__ */ l(
1050
1040
  "button",
1051
1041
  {
1052
- className: `btn btn-primary flex-1 ${i ? "loading" : ""}`,
1042
+ className: `btn btn-primary flex-1 ${s ? "loading" : ""}`,
1053
1043
  onClick: async () => {
1054
- if (!(!b || i)) {
1055
- c(!0);
1044
+ if (!(!f || s)) {
1045
+ d(!0);
1056
1046
  try {
1057
1047
  const h = `zeitgutschein-${t}h-${n.name.replace(/\s+/g, "-").toLowerCase()}.pdf`;
1058
- await Be({
1059
- frontTemplateSrc: o.front,
1060
- backTemplateSrc: o.back,
1061
- templateWidth: o.width,
1062
- templateHeight: o.height,
1063
- layout: d,
1064
- portrait: p,
1048
+ await Me({
1049
+ frontTemplateSrc: i.front,
1050
+ backTemplateSrc: i.back,
1051
+ templateWidth: i.width,
1052
+ templateHeight: i.height,
1053
+ layout: c,
1054
+ portrait: u,
1065
1055
  portraitZoom: r.zoom,
1066
1056
  name: n.name,
1067
1057
  email: n.email,
1068
1058
  phone: n.phone,
1069
- description: u,
1059
+ description: g,
1070
1060
  filename: h
1071
1061
  });
1072
1062
  } catch (h) {
1073
1063
  console.error("PDF export failed:", h);
1074
1064
  } finally {
1075
- c(!1);
1065
+ d(!1);
1076
1066
  }
1077
1067
  }
1078
1068
  },
1079
- disabled: !b || i,
1080
- children: i ? /* @__PURE__ */ f($, { children: [
1069
+ disabled: !f || s,
1070
+ children: s ? /* @__PURE__ */ m(M, { children: [
1081
1071
  /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-sm" }),
1082
- s.export.exporting
1083
- ] }) : /* @__PURE__ */ f($, { children: [
1072
+ o.export.exporting
1073
+ ] }) : /* @__PURE__ */ m(M, { children: [
1084
1074
  /* @__PURE__ */ l(
1085
1075
  "svg",
1086
1076
  {
@@ -1100,16 +1090,16 @@ function Ze() {
1100
1090
  )
1101
1091
  }
1102
1092
  ),
1103
- s.export.button
1093
+ o.export.button
1104
1094
  ] })
1105
1095
  }
1106
1096
  );
1107
1097
  }
1108
- function Re() {
1109
- const e = y((n) => n.voucherConfig.language), t = y((n) => n.setLanguage), a = (n) => {
1098
+ function Ue() {
1099
+ const e = w((n) => n.voucherConfig.language), t = w((n) => n.setLanguage), a = (n) => {
1110
1100
  t(n);
1111
1101
  };
1112
- return /* @__PURE__ */ f("div", { className: "join", children: [
1102
+ return /* @__PURE__ */ m("div", { className: "join", children: [
1113
1103
  /* @__PURE__ */ l(
1114
1104
  "button",
1115
1105
  {
@@ -1128,22 +1118,22 @@ function Re() {
1128
1118
  )
1129
1119
  ] });
1130
1120
  }
1131
- function Xe() {
1132
- const e = y((a) => a.voucherConfig.language), t = D(e);
1133
- return /* @__PURE__ */ f("div", { className: "navbar bg-currency-green text-currency-cream shadow-lg", children: [
1121
+ function nt() {
1122
+ const e = w((a) => a.voucherConfig.language), t = z(e);
1123
+ return /* @__PURE__ */ m("div", { className: "navbar bg-currency-green text-currency-cream shadow-lg", children: [
1134
1124
  /* @__PURE__ */ l("div", { className: "navbar-start", children: /* @__PURE__ */ l("a", { className: "btn btn-ghost text-xl font-currency font-bold", children: t.header.title }) }),
1135
1125
  /* @__PURE__ */ l("div", { className: "navbar-center hidden sm:flex", children: /* @__PURE__ */ l("span", { className: "text-sm opacity-80", children: t.header.subtitle }) }),
1136
- /* @__PURE__ */ l("div", { className: "navbar-end", children: /* @__PURE__ */ l(Re, {}) })
1126
+ /* @__PURE__ */ l("div", { className: "navbar-end", children: /* @__PURE__ */ l(Ue, {}) })
1137
1127
  ] });
1138
1128
  }
1139
- const M = "/", $e = {
1129
+ const U = "/", Fe = {
1140
1130
  id: "time-voucher-classic-de",
1141
1131
  name: "Zeitgutschein Classic",
1142
1132
  type: "time-voucher",
1143
1133
  category: "classic",
1144
1134
  images: {
1145
- front: `${M}templates/front_hdpi_de.jpg`,
1146
- back: `${M}templates/back_hdpi_de.jpg`,
1135
+ front: `${U}templates/front_hdpi_de.jpg`,
1136
+ back: `${U}templates/back_hdpi_de.jpg`,
1147
1137
  width: 6144,
1148
1138
  height: 4096
1149
1139
  },
@@ -1190,24 +1180,24 @@ const M = "/", $e = {
1190
1180
  ],
1191
1181
  layout: {
1192
1182
  front: {
1193
- portrait: A.front.portrait,
1194
- name: A.front.namePlate
1183
+ portrait: R.front.portrait,
1184
+ name: R.front.namePlate
1195
1185
  },
1196
1186
  back: {
1197
- name: A.back.namePlate,
1198
- contactInfo: A.back.contactInfo,
1199
- description: A.back.description
1187
+ name: R.back.namePlate,
1188
+ contactInfo: R.back.contactInfo,
1189
+ description: R.back.description
1200
1190
  }
1201
1191
  },
1202
1192
  languages: ["de"]
1203
- }, Me = {
1193
+ }, We = {
1204
1194
  id: "time-voucher-classic-en",
1205
1195
  name: "Time Voucher Classic",
1206
1196
  type: "time-voucher",
1207
1197
  category: "classic",
1208
1198
  images: {
1209
- front: `${M}templates/front_ldpi_en.png`,
1210
- back: `${M}templates/back_ldpi_en.png`,
1199
+ front: `${U}templates/front_ldpi_en.png`,
1200
+ back: `${U}templates/back_ldpi_en.png`,
1211
1201
  width: 1536,
1212
1202
  height: 1024
1213
1203
  },
@@ -1254,20 +1244,20 @@ const M = "/", $e = {
1254
1244
  ],
1255
1245
  layout: {
1256
1246
  front: {
1257
- portrait: T.front.portrait,
1258
- name: T.front.namePlate
1247
+ portrait: B.front.portrait,
1248
+ name: B.front.namePlate
1259
1249
  },
1260
1250
  back: {
1261
- name: T.back.namePlate,
1262
- contactInfo: T.back.contactInfo,
1263
- description: T.back.description
1251
+ name: B.back.namePlate,
1252
+ contactInfo: B.back.contactInfo,
1253
+ description: B.back.description
1264
1254
  }
1265
1255
  },
1266
1256
  languages: ["en"]
1267
1257
  }, X = [
1268
- $e,
1269
- Me
1270
- ], ze = {
1258
+ Fe,
1259
+ We
1260
+ ], Ke = {
1271
1261
  async listTemplates(e) {
1272
1262
  let t = [...X];
1273
1263
  return e != null && e.type && (t = t.filter((a) => a.type === e.type)), e != null && e.category && (t = t.filter((a) => a.category === e.category)), e != null && e.language && (t = t.filter((a) => a.languages.includes(e.language))), t;
@@ -1279,61 +1269,61 @@ const M = "/", $e = {
1279
1269
  return t;
1280
1270
  }
1281
1271
  };
1282
- function Je(e) {
1272
+ function at(e) {
1283
1273
  return e === "de" ? "time-voucher-classic-de" : "time-voucher-classic-en";
1284
1274
  }
1285
- let z = ze;
1286
- function Qe(e) {
1287
- z = e;
1275
+ let F = Ke;
1276
+ function rt(e) {
1277
+ F = e;
1288
1278
  }
1289
- function et() {
1290
- return z;
1279
+ function ot() {
1280
+ return F;
1291
1281
  }
1292
- async function tt(e) {
1293
- return z.listTemplates(e);
1282
+ async function it(e) {
1283
+ return F.listTemplates(e);
1294
1284
  }
1295
- async function nt(e) {
1296
- return z.getTemplate(e);
1285
+ async function st(e) {
1286
+ return F.getTemplate(e);
1297
1287
  }
1298
1288
  export {
1299
- Se as ApiKeyModal,
1300
- Ve as BillPreview,
1301
- Ze as ExportButton,
1302
- Xe as Header,
1303
- A as LAYOUT_HDPI,
1304
- T as LAYOUT_LDPI,
1305
- Re as LanguageToggle,
1306
- Oe as PersonalInfoForm,
1307
- Ye as PortraitUpload,
1308
- Ce as TEMPLATES,
1309
- qe as VoucherConfig,
1310
- _e as downloadBlob,
1311
- Le as drawContactInfo,
1312
- Ae as drawMultilineText,
1313
- Te as drawOvalPortrait,
1289
+ De as ApiKeyModal,
1290
+ Qe as BillPreview,
1291
+ tt as ExportButton,
1292
+ nt as Header,
1293
+ R as LAYOUT_HDPI,
1294
+ B as LAYOUT_LDPI,
1295
+ Ue as LanguageToggle,
1296
+ Ve as PersonalInfoForm,
1297
+ Xe as PortraitUpload,
1298
+ _e as TEMPLATES,
1299
+ Je as VoucherConfig,
1300
+ He as downloadBlob,
1301
+ $e as drawContactInfo,
1302
+ Re as drawMultilineText,
1303
+ Be as drawOvalPortrait,
1314
1304
  ae as drawTemplate,
1315
1305
  re as drawText,
1316
- je as enhancePortrait,
1317
- Pe as enhancePortraitFallback,
1318
- Be as exportBillAsPDF,
1306
+ Ze as enhancePortrait,
1307
+ Te as enhancePortraitFallback,
1308
+ Me as exportBillAsPDF,
1319
1309
  J as formatDescription,
1320
- De as generateBillPDF,
1321
- Y as getApiKey,
1322
- Je as getDefaultTemplateId,
1310
+ ze as generateBillPDF,
1311
+ q as getApiKey,
1312
+ at as getDefaultTemplateId,
1323
1313
  te as getLayout,
1324
1314
  ne as getTemplate,
1325
- nt as getTemplateById,
1326
- et as getTemplateProvider,
1327
- Ie as hasApiKey,
1328
- tt as listTemplates,
1329
- j as loadImage,
1330
- Ee as removeBackground,
1315
+ st as getTemplateById,
1316
+ ot as getTemplateProvider,
1317
+ Ce as hasApiKey,
1318
+ it as listTemplates,
1319
+ Y as loadImage,
1320
+ Ae as removeBackground,
1331
1321
  ie as renderBackSide,
1332
1322
  oe as renderFrontSide,
1333
- ke as setApiKey,
1334
- Qe as setTemplateProvider,
1335
- ze as staticTemplateProvider,
1336
- D as t,
1337
- Ge as useBillCanvasRefs,
1338
- y as useBillStore
1323
+ Se as setApiKey,
1324
+ rt as setTemplateProvider,
1325
+ Ke as staticTemplateProvider,
1326
+ z as t,
1327
+ et as useBillCanvasRefs,
1328
+ w as useBillStore
1339
1329
  };