@antontranelis/money-printer 1.0.85 → 1.0.86
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.cjs +3 -3
- package/dist/index.js +71 -71
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),g=require("react"),tn=require("zustand"),nn=require("zustand/middleware"),an=require("jspdf");var ge=typeof document<"u"?document.currentScript:null;const rn=1024,ct=1200,le=new Map;let F=null,lt=null;function Qe(e,t){return F||(F=document.createElement("canvas"),lt=F.getContext("2d",{willReadFrequently:!0})),(F.width!==e||F.height!==t)&&(F.width=e,F.height=t),lt}function pe(e){const t=le.get(e);return t?Promise.resolve(t):new Promise((n,a)=>{const r=new Image;r.onload=()=>{if(le.size>10){const l=le.keys().next().value;l&&le.delete(l)}le.set(e,r),n(r)},r.onerror=()=>a(new Error("Failed to load image")),r.src=e})}function on(){le.clear()}async function pt(e,t=rn){const n=await pe(e),a=Math.max(n.width,n.height);if(a<=t)return e;const r=t/a,l=Math.round(n.width*r),i=Math.round(n.height*r),s=document.createElement("canvas"),o=s.getContext("2d");if(!o)throw new Error("Failed to get canvas context");return s.width=l,s.height=i,o.drawImage(n,0,0,l,i),s.toDataURL("image/jpeg",.9)}async function ft(e){const t=await pe(e),n=Math.max(t.width,t.height);if(n<=ct){const o=document.createElement("canvas"),u=o.getContext("2d");if(!u)throw new Error("Failed to get canvas context");return o.width=t.width,o.height=t.height,u.drawImage(t,0,0),o.toDataURL("image/png")}const a=ct/n,r=Math.round(t.width*a),l=Math.round(t.height*a),i=document.createElement("canvas"),s=i.getContext("2d");if(!s)throw new Error("Failed to get canvas context");return i.width=r,i.height=l,s.drawImage(t,0,0,r,l),i.toDataURL("image/png")}async function ze(e,t,n,a=0){const[r,l]=await Promise.all([pe(e),pe(t)]),i=Qe(r.width,r.height);if(i.clearRect(0,0,r.width,r.height),n>0){const s=a*20;i.save(),i.globalAlpha=n,s>0&&(i.filter=`blur(${s}px)`),i.drawImage(l,0,0,r.width,r.height),i.restore()}return i.drawImage(r,0,0),F.toDataURL("image/png")}async function bt(e,t=.5,n=40){const a=await pe(e),r=Qe(a.width,a.height);r.clearRect(0,0,a.width,a.height),r.drawImage(a,0,0);const l=r.getImageData(0,0,a.width,a.height),i=l.data,s=new Uint32Array(i.buffer),o=1+t*.8,u=1-t,h=n%360/360;for(let f=0;f<s.length;f++){const p=s[f],m=p&255,y=p>>8&255,k=p>>16&255,d=p>>24&255;if(d===0)continue;let E=(((77*m+150*y+29*k>>8)/255-.5)*o+.5)*255;E<0?E=0:E>255&&(E=255);const v=E/255,S=.12,[L,P,D]=xt(h,S,v),j=m*u+L*t|0,R=y*u+P*t|0,C=k*u+D*t|0;s[f]=d<<24|C<<16|R<<8|j}return r.putImageData(l,0,0),F.toDataURL("image/png")}function sn(e,t,n){e/=255,t/=255,n/=255;const a=Math.max(e,t,n),r=Math.min(e,t,n),l=(a+r)/2;let i=0,s=0;if(a!==r){const o=a-r;switch(s=l>.5?o/(2-a-r):o/(a+r),a){case e:i=((t-n)/o+(t<n?6:0))/6;break;case t:i=((n-e)/o+2)/6;break;case n:i=((e-t)/o+4)/6;break}}return[i,s,l]}function xt(e,t,n){if(t===0){const i=Math.round(n*255);return[i,i,i]}const a=(i,s,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?i+(s-i)*6*o:o<1/2?s:o<2/3?i+(s-i)*(2/3-o)*6:i),r=n<.5?n*(1+t):n+t-n*t,l=2*n-r;return[Math.round(a(l,r,e+1/3)*255),Math.round(a(l,r,e)*255),Math.round(a(l,r,e-1/3)*255)]}const cn=29,ln=5;async function wt(e,t){if(Math.abs(t-cn)<=ln)return e;const n=await pe(e),a=Qe(n.width,n.height);a.clearRect(0,0,n.width,n.height),a.drawImage(n,0,0);const r=a.getImageData(0,0,n.width,n.height),l=r.data,i=new Uint32Array(l.buffer),s=t%360/360,o=20/360,u=45/360,h=i.length;for(let f=0;f<h;f++){const p=i[f],m=p&255,y=p>>8&255,k=p>>16&255,d=p>>24&255;if(d===0)continue;const[I,E,v]=sn(m,y,k);if(E<.08||I<o||I>u)continue;const S=s,L=Math.min(E,.05),[P,D,j]=xt(S,L,v);i[f]=d<<24|j<<16|D<<8|P}return a.putImageData(r,0,0),F.toDataURL("image/png")}const me=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ge&&ge.tagName.toUpperCase()==="SCRIPT"&&ge.src||new URL("index.cjs",document.baseURI).href}<"u"&&"/"||"/",X={background:`${me}templates/background.webp`,frontFrame:`${me}templates/front_frame.webp`,backFrame:`${me}templates/back_frame.webp`},he={1:`${me}templates/1.png`,5:`${me}templates/5.png`,10:`${me}templates/10.png`},yt={de:{banner:{1:"EINE STUNDE",5:"FÜNF STUNDEN",10:"ZEHN STUNDEN"}},en:{banner:{1:"ONE HOUR",5:"FIVE HOURS",10:"TEN HOURS"}}},ne=3633,ae=1920,Ne=.5,un=Math.round(ne*Ne),dn=Math.round(ae*Ne),vt=320,kt=335,$={badges:{topLeft:{x:286,y:235},topRight:{x:3340,y:230},bottomLeft:{x:282,y:1665},bottomRight:{x:3345,y:1665}},banner:{centerX:1816,centerY:3820,radius:3610,fontSize:103,color:"#2a3a2a"}},Ee=new Map,ie=new Map,Ve=new Map,Ke=new Map,Fe=new Map;function It(e,t,n,a,r,l,i){e.save(),e.font=`900 ${l}px "Times New Roman", Georgia, serif`,e.fillStyle=i,e.textAlign="center",e.textBaseline="middle";const o=e.measureText(t).width/r,u=-Math.PI/2-o/2,h=t.split(""),f=[];for(const m of h)f.push(e.measureText(m).width);let p=u;for(let m=0;m<h.length;m++){const y=h[m],k=f[m],d=p+k/2/r,I=n+r*Math.cos(d),E=a+r*Math.sin(d);e.save(),e.translate(I,E),e.rotate(d+Math.PI/2),e.fillText(y,0,0),e.restore(),p+=k/r}e.restore()}let W={background:null,frontFrame:null,backFrame:null,badges:{1:null,5:null,10:null}};async function gn(){const[e,t,n,a,r,l]=await Promise.all([B(X.background),B(X.frontFrame),B(X.backFrame),B(he[1]),B(he[5]),B(he[10])]);W={background:e,frontFrame:t,backFrame:n,badges:{1:a,5:r,10:l}}}function mn(e,t){const n=Math.round(ne*e),a=Math.round(ae*e),r=document.createElement("canvas");r.width=n,r.height=a;const l=r.getContext("2d");if(!l)throw new Error("Failed to get canvas context");l.drawImage(t,0,0,n,a);const i=e<1?.8:.95;return r.toDataURL("image/jpeg",i)}function hn(e,t){const n=Math.round(ne*e),a=Math.round(ae*e),r=document.createElement("canvas");r.width=n,r.height=a;const l=r.getContext("2d");if(!l)throw new Error("Failed to get canvas context");const i=vt*e,s=kt*e,o=$.badges,u=(h,f)=>{const p=f/2,m=h.x*e-p,y=h.y*e-p;l.drawImage(t,m,y,f,f)};return u(o.topLeft,i),u(o.topRight,i),u(o.bottomLeft,s),u(o.bottomRight,s),r.toDataURL("image/png")}function Tt(e,t,n,a=1){const r=yt[n].banner[t];It(e,r,$.banner.centerX*a,$.banner.centerY*a,$.banner.radius*a,$.banner.fontSize*a,$.banner.color)}function Et(e,t,n,a,r,l,i){const s=Math.round(ne*a),o=Math.round(ae*a),u=document.createElement("canvas");u.width=s,u.height=o;const h=u.getContext("2d");if(!h)throw new Error("Failed to get canvas context");h.drawImage(r,0,0,s,o);{const p=vt*a,m=kt*a,y=$.badges,k=(d,I)=>{const E=I/2,v=d.x*a-E,S=d.y*a-E;h.drawImage(i,v,S,I,I)};k(y.topLeft,p),k(y.topRight,p),k(y.bottomLeft,m),k(y.bottomRight,m)}if(h.drawImage(l,0,0,s,o),n==="front"){const p=yt[t].banner[e];It(h,p,$.banner.centerX*a,$.banner.centerY*a,$.banner.radius*a,$.banner.fontSize*a,$.banner.color)}const f=a<1?.8:.95;return u.toDataURL("image/jpeg",f)}async function St(e,t,n){const a=`${e}-${t}-${n}`;if(Ee.has(a))return Ee.get(a);const r=W.background||await B(X.background),l=n==="front"?W.frontFrame||await B(X.frontFrame):W.backFrame||await B(X.backFrame),i=W.badges[e]||await B(he[e]),s=Et(e,t,n,Ne,r,l,i);return Ee.set(a,s),s}async function qe(e,t,n){const a=`${e}-${t}-${n}`;if(ie.has(a))return ie.get(a);const r=W.background||await B(X.background),l=n==="front"?W.frontFrame||await B(X.frontFrame):W.backFrame||await B(X.backFrame),i=W.badges[e]||await B(he[e]),s=Et(e,t,n,1,r,l,i);if(ie.size>4){const o=ie.keys().next().value;o&&ie.delete(o)}return ie.set(a,s),s}function pn(){return{width:ne,height:ae}}function Pt(){Ee.clear(),ie.clear(),Ve.clear(),Ke.clear(),Fe.clear()}async function Ze(e,t,n="front",a=Ne){const r=`bg-${a}`;let l=Ve.get(r);if(!l){const h=W.background||await B(X.background);l=mn(a,h),Ve.set(r,l)}const i=`badges-${e}-${a}`;let s=Ke.get(i);if(!s){const h=W.badges[e]||await B(he[e]);s=hn(a,h),Ke.set(i,s)}const o=`${n}-${a}`;let u=Fe.get(o);if(!u){const h=n==="front"?W.frontFrame||await B(X.frontFrame):W.backFrame||await B(X.backFrame),f=Math.round(ne*a),p=Math.round(ae*a),m=document.createElement("canvas");m.width=f,m.height=p;const y=m.getContext("2d");if(!y)throw new Error("Failed to get canvas context");y.drawImage(h,0,0,f,p),u=m.toDataURL("image/png"),Fe.set(o,u)}return{background:l,badges:s,frame:u}}async function fn(){const e=[1,5,10],t=["de","en"],n=["front","back"],a=[];for(const r of e)for(const l of t)for(const i of n)a.push(St(r,l,i));await Promise.all(a)}const Se=new Map,se=new Map;function Lt(){se.clear(),Se.clear()}async function B(e){return Se.has(e)?Se.get(e):new Promise((t,n)=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{Se.set(e,a),t(a)},a.onerror=n,a.src=e})}function ce(e,t,n,a){e.drawImage(t,0,0,n,a)}const bn=29,xn=5;async function Rt(e,t,n,a){if(Math.abs(t-bn)<=xn)return B(e);const r=`${e}:${t}:${n}x${a}`;if(se.has(r))return B(se.get(r));const l=await B(e),i=document.createElement("canvas");i.width=n,i.height=a;const s=i.getContext("2d");if(!s)throw new Error("Failed to get canvas context");s.drawImage(l,0,0,n,a);const o=i.toDataURL("image/png"),u=await wt(o,t);if(se.size>20){const h=se.keys().next().value;h&&se.delete(h)}return se.set(r,u),B(u)}function wn(e,t,n,a,r,l="de"){e.save(),e.beginPath(),e.ellipse(t,n,a,r,0,0,Math.PI*2),e.closePath(),e.setLineDash([20,10]),e.strokeStyle="rgba(100, 100, 100, 0.4)",e.lineWidth=3,e.stroke(),e.restore()}function Ct(e,t,n,a,r,l,i=1,s=0,o=0){e.save(),e.beginPath(),e.ellipse(n,a,r,l,0,0,Math.PI*2),e.closePath(),e.clip();const u=t.width/t.height,h=r/l,f=r*2,p=l*2;let m,y;u>h?(y=p,m=p*u):(m=f,y=f/u),m*=i,y*=i;const k=Math.max(0,(m-f)/2),d=Math.max(0,(y-p)/2),I=n-m/2+s*k,E=a-y/2+o*d;e.drawImage(t,I,E,m,y),e.restore()}function et(e,t,n,a="#2a3a2a"){e.save(),e.font=`${n.fontSize}px "Times New Roman", serif`,e.textAlign=n.align||"center",e.textBaseline="middle",e.fillStyle=a,n.maxWidth?e.fillText(t,n.x,n.y,n.maxWidth):e.fillText(t,n.x,n.y),e.restore()}function Bt(e,t,n,a="#2a3a2a"){e.save(),e.font=`${n.fontSize}px "Times New Roman", serif`,e.textAlign=n.align||"center",e.textBaseline="top",e.fillStyle=a;const r=n.maxWidth||400,l=n.lineHeight||n.fontSize*1.4,i=t.split(" "),s=[];let o="";for(const f of i){const p=o?`${o} ${f}`:f;e.measureText(p).width>r&&o?(s.push(o),o=f):o=p}o&&s.push(o);const u=s.length*l;let h=n.y-u/2;for(const f of s)e.fillText(f,n.x,h),h+=l;e.restore()}function Nt(e,t,n,a,r,l="#2a3a2a"){e.save(),e.font=`${r.fontSize}px "Times New Roman", serif`,e.textAlign=r.align||"center",e.textBaseline="middle",e.fillStyle=l;const i=r.lineHeight||r.fontSize*1.8,s=[t,n,a].filter(Boolean),o=(s.length-1)*i;let u=r.y-o/2;for(const h of s)h&&(e.fillText(h,r.x,u),u+=i);e.restore()}function yn(e,t,n,a="#2a3a2a"){e.save(),e.strokeStyle=a,e.lineWidth=Math.max(2,t.labelFontSize/16),e.beginPath(),e.moveTo(t.x-t.width/2,t.y),e.lineTo(t.x+t.width/2,t.y),e.stroke(),e.font=`${t.labelFontSize}px "Times New Roman", serif`,e.textAlign="center",e.textBaseline="top",e.fillStyle=a,e.fillText(n,t.x,t.y+t.labelFontSize*.3),e.restore()}async function jt(e,t,n,a,r,l,i,s,o,u=1,h=0,f=0,p=0,m=1,y="de"){const k=e.getContext("2d");if(!k)return;const d=document.createElement("canvas");d.width=s,d.height=o;const I=d.getContext("2d");if(!I)return;I.clearRect(0,0,s,o);const E=await Rt(t,p,s,o);ce(I,E,s,o);const v=await B(n);if(ce(I,v,s,o),r)try{const P=await B(r);Ct(I,P,i.portrait.x,i.portrait.y,i.portrait.radiusX,i.portrait.radiusY,u,h,f)}catch(P){console.error("Failed to load portrait:",P)}else wn(I,i.portrait.x,i.portrait.y,i.portrait.radiusX,i.portrait.radiusY,y);const S=await B(a);ce(I,S,s,o);const L=s/3633;Tt(I,m,y,L),l&&et(I,l,i.namePlate),e.width=s,e.height=o,k.drawImage(d,0,0)}async function At(e,t,n,a,r,l,i,s,o,u,h,f=0,p=1,m="de"){const y=e.getContext("2d");if(!y)return;const k=document.createElement("canvas");k.width=u,k.height=h;const d=k.getContext("2d");if(!d)return;d.clearRect(0,0,u,h);const I=await Rt(t,f,u,h);ce(d,I,u,h);const E=await B(n);ce(d,E,u,h);const v=await B(a);ce(d,v,u,h);const S=u/3633;if(Tt(d,p,m,S),o.contactInfo&&(r||l||i)&&Nt(d,r,l,i,o.contactInfo),o.description&&s&&Bt(d,s,o.description),r&&et(d,r,o.namePlate),o.signature){const L=m==="de"?"Unterschrift":"Signature";yn(d,o.signature,L)}e.width=u,e.height=h,y.drawImage(k,0,0)}const Le="money-generator-portrait",Re="money-generator-bg-removed";async function vn(e){try{if(localStorage.removeItem(Le),!e)return;const t=await ft(e);try{localStorage.setItem(Le,t)}catch(n){console.warn("Could not persist portrait to localStorage:",n)}}catch(t){console.warn("Error processing portrait for storage:",t)}}async function kn(e){try{if(localStorage.removeItem(Re),!e)return;const t=await ft(e);try{localStorage.setItem(Re,t)}catch(n){console.warn("Could not persist bg-removed image to localStorage:",n)}}catch(t){console.warn("Error processing bg-removed image for storage:",t)}}function In(){try{return localStorage.getItem(Le)}catch{return null}}function Tn(){try{return localStorage.getItem(Re)}catch{return null}}function En(){try{localStorage.removeItem(Le),localStorage.removeItem(Re)}catch{}}function Sn(){return(typeof navigator<"u"?navigator.language:"de").toLowerCase().startsWith("de")?"de":"en"}const Ce=Sn(),ut={personalInfo:{name:"",email:"",phone:""},voucherConfig:{hours:1,description:"",language:Ce,templateHue:29},portrait:{original:null,enhanced:null,useEnhanced:!1,zoom:1,panX:0,panY:0,rawImage:null,bgRemovedImage:null,bgRemoved:!1,bgOpacity:0,bgBlur:0,engravingIntensity:0},currentSide:"front",isEnhancing:!1,isExporting:!1,appLanguage:Ce},w=tn.create()(nn.persist(e=>({...ut,setPersonalInfo:t=>e(n=>({personalInfo:{...n.personalInfo,...t}})),setVoucherConfig:t=>e(n=>({voucherConfig:{...n.voucherConfig,...t}})),setPortrait:(t,n=null)=>(vn(t),e(a=>({portrait:{...a.portrait,original:t,enhanced:n,useEnhanced:!1,zoom:a.portrait.original&&t?a.portrait.zoom:1,panX:a.portrait.original&&t?a.portrait.panX:0,panY:a.portrait.original&&t?a.portrait.panY:0}}))),setEnhancedPortrait:t=>e(n=>({portrait:{...n.portrait,enhanced:t,useEnhanced:t!==null}})),toggleUseEnhanced:()=>e(t=>({portrait:{...t.portrait,useEnhanced:t.portrait.enhanced?!t.portrait.useEnhanced:!1}})),setPortraitZoom:t=>e(n=>({portrait:{...n.portrait,zoom:t}})),setPortraitPan:(t,n)=>e(a=>({portrait:{...a.portrait,panX:t,panY:n}})),setPortraitRawImage:t=>e(n=>({portrait:{...n.portrait,rawImage:t}})),setPortraitBgRemoved:(t,n)=>(n!==void 0&&kn(n),e(a=>({portrait:{...a.portrait,bgRemoved:t,bgRemovedImage:n!==void 0?n:a.portrait.bgRemovedImage}}))),setPortraitBgOpacity:t=>e(n=>({portrait:{...n.portrait,bgOpacity:t}})),setPortraitBgBlur:t=>e(n=>({portrait:{...n.portrait,bgBlur:t}})),setPortraitEngravingIntensity:t=>e(n=>({portrait:{...n.portrait,engravingIntensity:t}})),setCurrentSide:t=>e({currentSide:t}),flipSide:()=>e(t=>({currentSide:t.currentSide==="front"?"back":"front"})),setIsEnhancing:t=>e({isEnhancing:t}),setIsExporting:t=>e({isExporting:t}),setAppLanguage:t=>e({appLanguage:t}),setBillLanguage:t=>e(n=>({voucherConfig:{...n.voucherConfig,language:t}})),setHours:t=>e(n=>({voucherConfig:{...n.voucherConfig,hours:t}})),setTemplateHue:t=>(Lt(),Pt(),e(n=>({voucherConfig:{...n.voucherConfig,templateHue:t}}))),reset:()=>(En(),e(ut))}),{name:"money-generator-storage",migrate:e=>{const t=e;return t!=null&&t.voucherConfig&&(t.voucherConfig.templateHue===void 0&&(t.voucherConfig.templateHue=29),t.voucherConfig.hours=1,t.voucherConfig.language=Ce),t&&(t.appLanguage=Ce),t},version:2,partialize:e=>({personalInfo:e.personalInfo,voucherConfig:{...e.voucherConfig},appLanguage:e.appLanguage,portrait:{original:null,enhanced:null,useEnhanced:e.portrait.useEnhanced,zoom:e.portrait.zoom,panX:e.portrait.panX,panY:e.portrait.panY,rawImage:null,bgRemovedImage:null,bgRemoved:e.portrait.bgRemoved,bgOpacity:e.portrait.bgOpacity,bgBlur:e.portrait.bgBlur,engravingIntensity:e.portrait.engravingIntensity},currentSide:"front",isEnhancing:!1,isExporting:!1})}));if(typeof window<"u"){const e=In(),t=Tn();e&&setTimeout(()=>{const n=w.getState();if(!n.portrait.original){const a=n.portrait.bgRemoved,r=t!==null;w.setState({portrait:{...n.portrait,original:e,rawImage:e,bgRemovedImage:t,bgRemoved:a&&r,bgOpacity:a&&r?n.portrait.bgOpacity:0,bgBlur:a&&r?n.portrait.bgBlur:0}})}},0)}const Pn={header:{title:"Money Generator",subtitle:"Erstelle deinen persönlichen Zeitgutschein"},form:{personalInfo:{title:"Persönliche Daten",name:"Name",namePlaceholder:"Dein Name",email:"E-Mail",emailPlaceholder:"deine@email.de",phone:"Telefon",phonePlaceholder:"+49 123 456789"},portrait:{title:"Portrait",upload:"Bild hochladen",dragDrop:"oder hierher ziehen",enhance:"Mit AI verbessern",enhancing:"Wird verbessert...",useOriginal:"Original verwenden",useEnhanced:"Verbessertes verwenden",zoom:"Zoom"},voucher:{title:"Gutschein",hours:"Stunden",hourLabel:"Stunde",hoursLabel:"Stunden",description:"Beschreibung",descriptionPlaceholder:"Was kann mit diesem Gutschein eingelöst werden?",billLanguage:"Schein-Sprache",billLanguageGerman:"Deutsch",billLanguageEnglish:"Englisch"},billColor:{title:"Scheinfarbe",label:"Farbton"}},preview:{front:"Vorderseite",back:"Rückseite",flip:"Umdrehen"},export:{button:"Als PDF herunterladen",exporting:"PDF wird erstellt...",success:"Download gestartet!"},bill:{descriptionText:"Für diesen Schein erhältst du {bannerText} meiner Zeit oder ein gleichwertiges Dankeschön.",bannerText:{1:"eine Stunde",5:"fünf Stunden",10:"zehn Stunden"}}},Ln={header:{title:"Money Generator",subtitle:"Create your personal time voucher"},form:{personalInfo:{title:"Personal Information",name:"Name",namePlaceholder:"Your name",email:"Email",emailPlaceholder:"your@email.com",phone:"Phone",phonePlaceholder:"+1 234 567890"},portrait:{title:"Portrait",upload:"Upload image",dragDrop:"or drag and drop",enhance:"Enhance with AI",enhancing:"Enhancing...",useOriginal:"Use original",useEnhanced:"Use enhanced",zoom:"Zoom"},voucher:{title:"Voucher",hours:"Hours",hourLabel:"hour",hoursLabel:"hours",description:"Description",descriptionPlaceholder:"What can be redeemed with this voucher?",billLanguage:"Bill Language",billLanguageGerman:"German",billLanguageEnglish:"English"},billColor:{title:"Bill Color",label:"Hue"}},preview:{front:"Front",back:"Back",flip:"Flip"},export:{button:"Download as PDF",exporting:"Creating PDF...",success:"Download started!"},bill:{descriptionText:"For this voucher, you will receive {bannerText} of my time or an equivalent appreciation in return.",bannerText:{1:"one hour",5:"five hours",10:"ten hours"}}},Rn={de:Pn,en:Ln};function re(e){return Rn[e]}function tt(e,t,n){if(n&&n.trim())return n;const a=re(e),r=a.bill.bannerText[t]||a.bill.bannerText[1];return a.bill.descriptionText.replace("{bannerText}",r)}function Cn(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function Bn(e){return e.replace(/\D/g,"").length>=6}function Nn({focusField:e,onFocused:t,onFormFocusChange:n}={}){const a=w(d=>d.appLanguage),r=w(d=>d.personalInfo),l=w(d=>d.setPersonalInfo),i=re(a),[s,o]=g.useState(!1),[u,h]=g.useState(!1),f=s&&r.email.trim()&&!Cn(r.email),p=u&&r.phone.trim()&&!Bn(r.phone),m=g.useRef(null),y=g.useRef(null),k=g.useRef(null);return g.useEffect(()=>{if(e){const d=e==="name"?m:e==="email"?y:k;setTimeout(()=>{var I,E;(I=d.current)==null||I.click(),(E=d.current)==null||E.focus(),setTimeout(()=>{var v;(v=d.current)==null||v.scrollIntoView({behavior:"smooth",block:"center"})},300),t==null||t()},100)}},[e,t]),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"form-control",children:[c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text font-medium",children:i.form.personalInfo.name})}),c.jsx("input",{ref:m,type:"text",name:"name",autoComplete:"name",placeholder:i.form.personalInfo.namePlaceholder,className:"input input-bordered w-full input-md",value:r.name,onChange:d=>l({name:d.target.value}),onFocus:d=>{n==null||n(!0),setTimeout(()=>d.target.scrollIntoView({behavior:"smooth",block:"center"}),300)},onBlur:()=>n==null?void 0:n(!1)})]}),c.jsxs("div",{className:"form-control",children:[c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text font-medium",children:i.form.personalInfo.email})}),c.jsx("input",{ref:y,type:"email",name:"email",autoComplete:"email",placeholder:i.form.personalInfo.emailPlaceholder,className:`input input-bordered w-full input-md ${f?"input-error":""}`,value:r.email,onChange:d=>l({email:d.target.value}),onFocus:d=>{n==null||n(!0),setTimeout(()=>d.target.scrollIntoView({behavior:"smooth",block:"center"}),300)},onBlur:()=>{o(!0),n==null||n(!1)}}),f&&c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text-alt text-error",children:a==="de"?"Bitte gib eine gültige E-Mail-Adresse ein":"Please enter a valid email address"})})]}),c.jsxs("div",{className:"form-control",children:[c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text font-medium",children:i.form.personalInfo.phone})}),c.jsx("input",{ref:k,type:"tel",name:"phone",autoComplete:"tel",placeholder:i.form.personalInfo.phonePlaceholder,className:`input input-bordered w-full input-md ${p?"input-error":""}`,value:r.phone,onChange:d=>l({phone:d.target.value}),onFocus:d=>{n==null||n(!0),setTimeout(()=>d.target.scrollIntoView({behavior:"smooth",block:"center"}),300)},onBlur:()=>{h(!0),n==null||n(!1)}}),p&&c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text-alt text-error",children:a==="de"?"Bitte gib eine gültige Telefonnummer ein":"Please enter a valid phone number"})})]})]})}const $e={},jn="https://api.stability.ai/v1/generation",An="https://api.stability.ai/v2beta/stable-image/edit/remove-background",Dt="stability_api_key";let fe=null;function Dn(e){fe=e}function Hn(){return fe}function Mn(){return fe!==null}const Un={vintage:"portrait in the style of vintage currency engraving, fine line work, crosshatching, sepia tones, detailed stippling, classic bank note portrait style",engraved:"portrait as detailed intaglio engraving, currency bill style, fine parallel lines, high contrast, official government portrait",currency:"portrait rendered as US dollar bill engraving, official currency portrait style, green tint, fine line engraving technique"},dt=[{width:1024,height:1024},{width:1152,height:896},{width:1216,height:832},{width:1344,height:768},{width:1536,height:640},{width:640,height:1536},{width:768,height:1344},{width:832,height:1216},{width:896,height:1152}];function On(e,t){const n=e/t;let a=dt[0],r=1/0;for(const l of dt){const i=l.width/l.height,s=Math.abs(n-i);s<r&&(r=s,a=l)}return a}function Yn(e){return new Promise((t,n)=>{const a=new Image;a.onload=()=>{const r=On(a.width,a.height),l=document.createElement("canvas");l.width=r.width,l.height=r.height;const i=l.getContext("2d");if(!i){n(new Error("Failed to get canvas context"));return}const s=a.width/a.height,o=r.width/r.height;let u=0,h=0,f=a.width,p=a.height;s>o?(f=a.height*o,u=(a.width-f)/2):(p=a.width/o,h=(a.height-p)/2),i.drawImage(a,u,h,f,p,0,0,r.width,r.height),t(l.toDataURL("image/png"))},a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function Ht(e){var i;const t=e.split(","),n=((i=t[0].match(/:(.*?);/))==null?void 0:i[1])||"image/png",a=atob(t[1]),r=a.length,l=new Uint8Array(r);for(let s=0;s<r;s++)l[s]=a.charCodeAt(s);return new Blob([l],{type:n})}function je(){var t;const e=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ge&&ge.tagName.toUpperCase()==="SCRIPT"&&ge.src||new URL("index.cjs",document.baseURI).href}<"u"&&($e==null?void 0:$e.VITE_STABILITY_API_KEY)||typeof process<"u"&&((t=process.env)==null?void 0:t.NEXT_PUBLIC_STABILITY_API_KEY);return e&&e!=="your-api-key-here"?e:typeof localStorage<"u"?localStorage.getItem(Dt):null}function Mt(e){localStorage.setItem(Dt,e)}function Pe(){return fe?!0:je()!==null}async function _n(e){const t=je();if(!t)throw new Error("No Stability AI API key configured");const{imageDataUrl:n,style:a,strength:r=.35}=e,l=await Yn(n),i=Ht(l),s=new FormData;s.append("init_image",i,"portrait.png"),s.append("init_image_mode","IMAGE_STRENGTH"),s.append("image_strength",String(1-r)),s.append("text_prompts[0][text]",Un[a]),s.append("text_prompts[0][weight]","1"),s.append("cfg_scale","7"),s.append("samples","1"),s.append("steps","30");const u=await fetch(`${jn}/stable-diffusion-xl-1024-v1-0/image-to-image`,{method:"POST",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"},body:s});if(!u.ok){const f=await u.text();throw console.error("Stability AI error:",f),u.status===401?new Error("Invalid API key"):u.status===402?new Error("Insufficient credits"):u.status===429?new Error("Rate limit exceeded. Please try again later."):new Error(`API error: ${u.status}`)}const h=await u.json();if(!h.artifacts||h.artifacts.length===0)throw new Error("No image generated");return`data:image/png;base64,${h.artifacts[0].base64}`}async function Ut(e){if(fe){const i=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageDataUrl:e})});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.error||`API error: ${i.status}`)}return(await i.json()).imageDataUrl}const t=je();if(!t)throw new Error("No Stability AI API key configured");const n=Ht(e),a=new FormData;a.append("image",n,"image.png"),a.append("output_format","png");const r=await fetch(An,{method:"POST",headers:{Authorization:`Bearer ${t}`,Accept:"image/*"},body:a});if(!r.ok){const i=await r.text();throw console.error("Stability AI remove background error:",i),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}`)}const l=await r.blob();return new Promise((i,s)=>{const o=new FileReader;o.onload=()=>i(o.result),o.onerror=()=>s(new Error("Failed to read result")),o.readAsDataURL(l)})}function Wn(){const[e,t]=g.useState(!1),[n,a]=g.useState(!1),[r,l]=g.useState(null),[i,s]=g.useState(()=>Pe());g.useEffect(()=>{s(Pe());const p=setTimeout(()=>{s(Pe())},150);return()=>clearTimeout(p)},[]);const o=g.useCallback(()=>l(null),[]),u=g.useCallback(p=>{Mt(p),s(!0),l(null)},[]),h=g.useCallback(async(p,m=.5,y=40)=>{t(!0),l(null);try{return await bt(p,m,y)}catch(k){const d=k instanceof Error?k.message:"Enhancement failed";throw l(d),k}finally{t(!1)}},[]),f=g.useCallback(async p=>{a(!0),l(null);try{return await Ut(p)}catch(m){const y=m instanceof Error?m.message:"Background removal failed";throw l(y),m}finally{a(!1)}},[]);return{enhance:h,removeBg:f,isEnhancing:e,isRemovingBg:n,error:r,hasKey:i,setApiKey:u,clearError:o}}function Ot({isOpen:e,onClose:t,onSubmit:n}){const a=w(u=>u.appLanguage),[r,l]=g.useState("");if(!e)return null;const i=u=>{u.preventDefault(),r.trim()&&(n(r.trim()),l(""),t())},o={de:{title:"Stability AI API Key",description:"Um die AI-Bildverbesserung zu nutzen, benötigst du einen Stability AI API Key. Du kannst ihn auf platform.stability.ai erhalten.",placeholder:"sk-...",submit:"Speichern",cancel:"Abbrechen",hint:"Der Key wird lokal in deinem Browser gespeichert."},en:{title:"Stability AI API Key",description:"To use AI image enhancement, you need a Stability AI API key. You can get one at platform.stability.ai.",placeholder:"sk-...",submit:"Save",cancel:"Cancel",hint:"The key is stored locally in your browser."}}[a];return c.jsxs("dialog",{className:"modal modal-open",children:[c.jsxs("div",{className:"modal-box",children:[c.jsx("h3",{className:"font-bold text-lg",children:o.title}),c.jsx("p",{className:"py-4 text-sm opacity-80",children:o.description}),c.jsxs("form",{onSubmit:i,children:[c.jsxs("div",{className:"form-control",children:[c.jsx("input",{type:"password",placeholder:o.placeholder,className:"input input-bordered w-full",value:r,onChange:u=>l(u.target.value),autoFocus:!0}),c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text-alt",children:o.hint})})]}),c.jsxs("div",{className:"modal-action",children:[c.jsx("button",{type:"button",className:"btn btn-ghost",onClick:t,children:o.cancel}),c.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!r.trim(),children:o.submit})]})]})]}),c.jsx("form",{method:"dialog",className:"modal-backdrop",children:c.jsx("button",{onClick:t,children:"close"})})]})}function ye({min:e,max:t,step:n,value:a,onChange:r,className:l="",disabled:i=!1}){const s=g.useRef(null),o=g.useRef(null),u=g.useRef(!1),[h,f]=g.useState(!1),p=(a-e)/(t-e)*100,m=g.useCallback(v=>{if(!s.current)return a;const S=s.current.getBoundingClientRect(),L=Math.max(0,Math.min(1,(v-S.left)/S.width)),P=t-e,D=e+L*P,j=Math.round(D/n)*n;return Math.max(e,Math.min(t,j))},[e,t,n,a]),y=g.useCallback(v=>{if(i)return;const S=v.touches[0];o.current={x:S.clientX,y:S.clientY,value:a,decided:!1},u.current=!1},[a,i]),k=g.useCallback(v=>{if(i||!o.current)return;const S=v.touches[0],L=Math.abs(S.clientX-o.current.x),P=Math.abs(S.clientY-o.current.y);if(!o.current.decided){if(L<8&&P<8)return;if(o.current.decided=!0,P>L){o.current=null;return}u.current=!0,f(!0)}if(u.current){const D=m(S.clientX);D!==a&&r(D)}},[i,m,r,a]),d=g.useCallback(v=>{if(o.current&&!o.current.decided){const S=v.changedTouches[0];if(S){const L=m(S.clientX);L!==a&&r(L)}}o.current=null,u.current=!1,f(!1)},[m,r,a]);g.useEffect(()=>{const v=s.current;if(!v)return;const S=L=>{u.current&&L.preventDefault()};return v.addEventListener("touchmove",S,{passive:!1}),()=>{v.removeEventListener("touchmove",S)}},[]);const I=g.useCallback(v=>{if(i)return;const S=m(v.clientX);r(S),f(!0);const L=D=>{const j=m(D.clientX);r(j)},P=()=>{f(!1),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",L),document.addEventListener("mouseup",P)},[i,m,r]),E=`calc(10px + (100% - 20px) * ${p/100})`;return c.jsxs("div",{ref:s,className:`relative h-10 flex items-center cursor-pointer overflow-visible ${i?"opacity-50 cursor-not-allowed":""}`,onTouchStart:y,onTouchMove:k,onTouchEnd:d,onMouseDown:I,children:[c.jsx("div",{className:"absolute h-2 bg-base-300 rounded-full inset-x-0"}),c.jsx("div",{className:`absolute h-2 rounded-full transition-colors ${l.includes("range-primary")?"bg-primary":l.includes("range-secondary")?"bg-secondary":"bg-primary"}`,style:{left:0,width:E}}),c.jsx("div",{className:`absolute w-5 h-5 rounded-full bg-base-100 border-2 shadow-md transition-transform ${h?"scale-110":""} ${l.includes("range-primary")?"border-primary":l.includes("range-secondary")?"border-secondary":"border-primary"}`,style:{left:E,transform:"translateX(-50%)"}})]})}function zn(){const e=w(b=>b.appLanguage),t=w(b=>b.portrait),n=w(b=>b.setPortrait),a=w(b=>b.setPortraitZoom),r=w(b=>b.setPortraitPan),l=w(b=>b.setPortraitRawImage),i=w(b=>b.setPortraitBgRemoved),s=w(b=>b.setPortraitBgOpacity),o=w(b=>b.setPortraitBgBlur),u=w(b=>b.setPortraitEngravingIntensity),{enhance:h,removeBg:f,isEnhancing:p,isRemovingBg:m,error:y,hasKey:k,setApiKey:d}=Wn(),I=re(e),E=g.useRef(null),[v,S]=g.useState(!1),[L,P]=g.useState(!1),D=g.useRef(null),j=g.useRef(null),R=t.rawImage,C=t.bgRemovedImage,Y=t.bgRemoved,q=t.bgOpacity,H=t.bgBlur,O=t.engravingIntensity;g.useEffect(()=>{t.original&&!t.rawImage&&l(t.original)},[t.original,t.rawImage,l]),g.useEffect(()=>()=>{D.current&&clearTimeout(D.current),j.current&&clearTimeout(j.current)},[]);const Z=w(b=>b.voucherConfig.templateHue),oe=g.useRef(Z),J=g.useCallback(async b=>{if(!b.type.startsWith("image/"))return;const T=new FileReader;T.onload=async M=>{var _;const A=(_=M.target)==null?void 0:_.result,V=await pt(A);on(),l(V),n(V),a(1),r(0,0),i(!1,null),s(0),o(0),u(0)},T.readAsDataURL(b)},[n,l,a,r,i,s,o,u]),be=g.useCallback(b=>{b.preventDefault(),S(!1);const T=b.dataTransfer.files[0];T&&J(T)},[J]),G=g.useCallback(b=>{b.preventDefault(),S(!0)},[]),Q=g.useCallback(b=>{b.preventDefault(),S(!1)},[]),K=()=>{var b;(b=E.current)==null||b.click()},xe=b=>{var M;const T=(M=b.target.files)==null?void 0:M[0];T&&J(T)},ee=g.useCallback(async(b,T,M)=>{try{return await h(b,T,M)}catch(A){return console.error("Enhancement failed:",A),b}},[h]),ve=g.useCallback(async b=>{try{const T=await f(b);return i(!0,T),T}catch(T){return console.error("Background removal failed:",T),b}},[f,i]),te=g.useCallback(async()=>{const b=w.getState(),T=b.portrait,M=b.voucherConfig.templateHue;if(!T.rawImage)return;let A;T.bgRemoved&&T.bgRemovedImage?A=await ze(T.bgRemovedImage,T.rawImage,T.bgOpacity,T.bgBlur):A=T.rawImage,T.engravingIntensity>0&&(A=await ee(A,T.engravingIntensity,M)),n(A)},[ee,n]);g.useEffect(()=>{if(oe.current===Z)return;oe.current=Z;const b=w.getState().portrait;b.engravingIntensity>0&&b.rawImage&&(D.current&&clearTimeout(D.current),D.current=setTimeout(te,150))},[Z,te]);const He=async()=>{if(!R)return;if(!Y&&!k){P(!0);return}if(!Y){const T=await ve(R),M=w.getState(),A=M.portrait,V=M.voucherConfig.templateHue;let _=await ze(T,R,A.bgOpacity,A.bgBlur);A.engravingIntensity>0&&(_=await ee(_,A.engravingIntensity,V)),n(_)}else{i(!1,null);const T=w.getState(),M=T.portrait.engravingIntensity,A=T.voucherConfig.templateHue;if(M>0){const V=await ee(R,M,A);n(V)}else n(R)}},we=b=>{u(b),D.current&&clearTimeout(D.current),R&&(D.current=setTimeout(te,150))},Me=async b=>{if(d(b),!R)return;const T=await ve(R),M=w.getState(),A=M.portrait,V=M.voucherConfig.templateHue;let _=await ze(T,R,A.bgOpacity,A.bgBlur);A.engravingIntensity>0&&(_=await ee(_,A.engravingIntensity,V)),n(_)},ke=b=>{s(b),j.current&&clearTimeout(j.current),!(!R||!C)&&(j.current=setTimeout(te,150))},Ie=b=>{o(b),j.current&&clearTimeout(j.current),!(!R||!C)&&(j.current=setTimeout(te,150))};return c.jsxs("div",{className:"space-y-4",children:[c.jsx("style",{children:`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),g=require("react"),nn=require("zustand"),an=require("zustand/middleware"),rn=require("jspdf");var ge=typeof document<"u"?document.currentScript:null;const on=1024,ct=1200,le=new Map;let F=null,lt=null;function Qe(e,t){return F||(F=document.createElement("canvas"),lt=F.getContext("2d",{willReadFrequently:!0})),(F.width!==e||F.height!==t)&&(F.width=e,F.height=t),lt}function pe(e){const t=le.get(e);return t?Promise.resolve(t):new Promise((n,a)=>{const r=new Image;r.onload=()=>{if(le.size>10){const l=le.keys().next().value;l&&le.delete(l)}le.set(e,r),n(r)},r.onerror=()=>a(new Error("Failed to load image")),r.src=e})}function pt(){le.clear()}async function ft(e,t=on){const n=await pe(e),a=Math.max(n.width,n.height);if(a<=t)return e;const r=t/a,l=Math.round(n.width*r),i=Math.round(n.height*r),s=document.createElement("canvas"),o=s.getContext("2d");if(!o)throw new Error("Failed to get canvas context");return s.width=l,s.height=i,o.drawImage(n,0,0,l,i),s.toDataURL("image/jpeg",.9)}async function bt(e){const t=await pe(e),n=Math.max(t.width,t.height);if(n<=ct){const o=document.createElement("canvas"),u=o.getContext("2d");if(!u)throw new Error("Failed to get canvas context");return o.width=t.width,o.height=t.height,u.drawImage(t,0,0),o.toDataURL("image/png")}const a=ct/n,r=Math.round(t.width*a),l=Math.round(t.height*a),i=document.createElement("canvas"),s=i.getContext("2d");if(!s)throw new Error("Failed to get canvas context");return i.width=r,i.height=l,s.drawImage(t,0,0,r,l),i.toDataURL("image/png")}async function ze(e,t,n,a=0){const[r,l]=await Promise.all([pe(e),pe(t)]),i=Qe(r.width,r.height);if(i.clearRect(0,0,r.width,r.height),n>0){const s=a*20;i.save(),i.globalAlpha=n,s>0&&(i.filter=`blur(${s}px)`),i.drawImage(l,0,0,r.width,r.height),i.restore()}return i.drawImage(r,0,0),F.toDataURL("image/png")}async function xt(e,t=.5,n=40){const a=await pe(e),r=Qe(a.width,a.height);r.clearRect(0,0,a.width,a.height),r.drawImage(a,0,0);const l=r.getImageData(0,0,a.width,a.height),i=l.data,s=new Uint32Array(i.buffer),o=1+t*.8,u=1-t,h=n%360/360;for(let f=0;f<s.length;f++){const p=s[f],m=p&255,y=p>>8&255,k=p>>16&255,d=p>>24&255;if(d===0)continue;let E=(((77*m+150*y+29*k>>8)/255-.5)*o+.5)*255;E<0?E=0:E>255&&(E=255);const v=E/255,S=.12,[L,P,D]=wt(h,S,v),j=m*u+L*t|0,R=y*u+P*t|0,C=k*u+D*t|0;s[f]=d<<24|C<<16|R<<8|j}return r.putImageData(l,0,0),F.toDataURL("image/png")}function sn(e,t,n){e/=255,t/=255,n/=255;const a=Math.max(e,t,n),r=Math.min(e,t,n),l=(a+r)/2;let i=0,s=0;if(a!==r){const o=a-r;switch(s=l>.5?o/(2-a-r):o/(a+r),a){case e:i=((t-n)/o+(t<n?6:0))/6;break;case t:i=((n-e)/o+2)/6;break;case n:i=((e-t)/o+4)/6;break}}return[i,s,l]}function wt(e,t,n){if(t===0){const i=Math.round(n*255);return[i,i,i]}const a=(i,s,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?i+(s-i)*6*o:o<1/2?s:o<2/3?i+(s-i)*(2/3-o)*6:i),r=n<.5?n*(1+t):n+t-n*t,l=2*n-r;return[Math.round(a(l,r,e+1/3)*255),Math.round(a(l,r,e)*255),Math.round(a(l,r,e-1/3)*255)]}const cn=29,ln=5;async function yt(e,t){if(Math.abs(t-cn)<=ln)return e;const n=await pe(e),a=Qe(n.width,n.height);a.clearRect(0,0,n.width,n.height),a.drawImage(n,0,0);const r=a.getImageData(0,0,n.width,n.height),l=r.data,i=new Uint32Array(l.buffer),s=t%360/360,o=20/360,u=45/360,h=i.length;for(let f=0;f<h;f++){const p=i[f],m=p&255,y=p>>8&255,k=p>>16&255,d=p>>24&255;if(d===0)continue;const[I,E,v]=sn(m,y,k);if(E<.08||I<o||I>u)continue;const S=s,L=Math.min(E,.05),[P,D,j]=wt(S,L,v);i[f]=d<<24|j<<16|D<<8|P}return a.putImageData(r,0,0),F.toDataURL("image/png")}const me=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ge&&ge.tagName.toUpperCase()==="SCRIPT"&&ge.src||new URL("index.cjs",document.baseURI).href}<"u"&&"/"||"/",X={background:`${me}templates/background.webp`,frontFrame:`${me}templates/front_frame.webp`,backFrame:`${me}templates/back_frame.webp`},he={1:`${me}templates/1.png`,5:`${me}templates/5.png`,10:`${me}templates/10.png`},vt={de:{banner:{1:"EINE STUNDE",5:"FÜNF STUNDEN",10:"ZEHN STUNDEN"}},en:{banner:{1:"ONE HOUR",5:"FIVE HOURS",10:"TEN HOURS"}}},ne=3633,ae=1920,Ne=.5,un=Math.round(ne*Ne),dn=Math.round(ae*Ne),kt=320,It=335,$={badges:{topLeft:{x:286,y:235},topRight:{x:3340,y:230},bottomLeft:{x:282,y:1665},bottomRight:{x:3345,y:1665}},banner:{centerX:1816,centerY:3820,radius:3610,fontSize:103,color:"#2a3a2a"}},Ee=new Map,ie=new Map,Ve=new Map,Ke=new Map,Fe=new Map;function Tt(e,t,n,a,r,l,i){e.save(),e.font=`900 ${l}px "Times New Roman", Georgia, serif`,e.fillStyle=i,e.textAlign="center",e.textBaseline="middle";const o=e.measureText(t).width/r,u=-Math.PI/2-o/2,h=t.split(""),f=[];for(const m of h)f.push(e.measureText(m).width);let p=u;for(let m=0;m<h.length;m++){const y=h[m],k=f[m],d=p+k/2/r,I=n+r*Math.cos(d),E=a+r*Math.sin(d);e.save(),e.translate(I,E),e.rotate(d+Math.PI/2),e.fillText(y,0,0),e.restore(),p+=k/r}e.restore()}let W={background:null,frontFrame:null,backFrame:null,badges:{1:null,5:null,10:null}};async function gn(){const[e,t,n,a,r,l]=await Promise.all([B(X.background),B(X.frontFrame),B(X.backFrame),B(he[1]),B(he[5]),B(he[10])]);W={background:e,frontFrame:t,backFrame:n,badges:{1:a,5:r,10:l}}}function mn(e,t){const n=Math.round(ne*e),a=Math.round(ae*e),r=document.createElement("canvas");r.width=n,r.height=a;const l=r.getContext("2d");if(!l)throw new Error("Failed to get canvas context");l.drawImage(t,0,0,n,a);const i=e<1?.8:.95;return r.toDataURL("image/jpeg",i)}function hn(e,t){const n=Math.round(ne*e),a=Math.round(ae*e),r=document.createElement("canvas");r.width=n,r.height=a;const l=r.getContext("2d");if(!l)throw new Error("Failed to get canvas context");const i=kt*e,s=It*e,o=$.badges,u=(h,f)=>{const p=f/2,m=h.x*e-p,y=h.y*e-p;l.drawImage(t,m,y,f,f)};return u(o.topLeft,i),u(o.topRight,i),u(o.bottomLeft,s),u(o.bottomRight,s),r.toDataURL("image/png")}function Et(e,t,n,a=1){const r=vt[n].banner[t];Tt(e,r,$.banner.centerX*a,$.banner.centerY*a,$.banner.radius*a,$.banner.fontSize*a,$.banner.color)}function St(e,t,n,a,r,l,i){const s=Math.round(ne*a),o=Math.round(ae*a),u=document.createElement("canvas");u.width=s,u.height=o;const h=u.getContext("2d");if(!h)throw new Error("Failed to get canvas context");h.drawImage(r,0,0,s,o);{const p=kt*a,m=It*a,y=$.badges,k=(d,I)=>{const E=I/2,v=d.x*a-E,S=d.y*a-E;h.drawImage(i,v,S,I,I)};k(y.topLeft,p),k(y.topRight,p),k(y.bottomLeft,m),k(y.bottomRight,m)}if(h.drawImage(l,0,0,s,o),n==="front"){const p=vt[t].banner[e];Tt(h,p,$.banner.centerX*a,$.banner.centerY*a,$.banner.radius*a,$.banner.fontSize*a,$.banner.color)}const f=a<1?.8:.95;return u.toDataURL("image/jpeg",f)}async function Pt(e,t,n){const a=`${e}-${t}-${n}`;if(Ee.has(a))return Ee.get(a);const r=W.background||await B(X.background),l=n==="front"?W.frontFrame||await B(X.frontFrame):W.backFrame||await B(X.backFrame),i=W.badges[e]||await B(he[e]),s=St(e,t,n,Ne,r,l,i);return Ee.set(a,s),s}async function qe(e,t,n){const a=`${e}-${t}-${n}`;if(ie.has(a))return ie.get(a);const r=W.background||await B(X.background),l=n==="front"?W.frontFrame||await B(X.frontFrame):W.backFrame||await B(X.backFrame),i=W.badges[e]||await B(he[e]),s=St(e,t,n,1,r,l,i);if(ie.size>4){const o=ie.keys().next().value;o&&ie.delete(o)}return ie.set(a,s),s}function pn(){return{width:ne,height:ae}}function Lt(){Ee.clear(),ie.clear(),Ve.clear(),Ke.clear(),Fe.clear()}async function Ze(e,t,n="front",a=Ne){const r=`bg-${a}`;let l=Ve.get(r);if(!l){const h=W.background||await B(X.background);l=mn(a,h),Ve.set(r,l)}const i=`badges-${e}-${a}`;let s=Ke.get(i);if(!s){const h=W.badges[e]||await B(he[e]);s=hn(a,h),Ke.set(i,s)}const o=`${n}-${a}`;let u=Fe.get(o);if(!u){const h=n==="front"?W.frontFrame||await B(X.frontFrame):W.backFrame||await B(X.backFrame),f=Math.round(ne*a),p=Math.round(ae*a),m=document.createElement("canvas");m.width=f,m.height=p;const y=m.getContext("2d");if(!y)throw new Error("Failed to get canvas context");y.drawImage(h,0,0,f,p),u=m.toDataURL("image/png"),Fe.set(o,u)}return{background:l,badges:s,frame:u}}async function fn(){const e=[1,5,10],t=["de","en"],n=["front","back"],a=[];for(const r of e)for(const l of t)for(const i of n)a.push(Pt(r,l,i));await Promise.all(a)}const Se=new Map,se=new Map;function Rt(){se.clear(),Se.clear(),pt()}async function B(e){return Se.has(e)?Se.get(e):new Promise((t,n)=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{Se.set(e,a),t(a)},a.onerror=n,a.src=e})}function ce(e,t,n,a){e.drawImage(t,0,0,n,a)}const bn=29,xn=5;async function Ct(e,t,n,a){if(Math.abs(t-bn)<=xn)return B(e);const r=`${e}:${t}:${n}x${a}`;if(se.has(r))return B(se.get(r));const l=await B(e),i=document.createElement("canvas");i.width=n,i.height=a;const s=i.getContext("2d");if(!s)throw new Error("Failed to get canvas context");s.drawImage(l,0,0,n,a);const o=i.toDataURL("image/png"),u=await yt(o,t);if(se.size>20){const h=se.keys().next().value;h&&se.delete(h)}return se.set(r,u),B(u)}function wn(e,t,n,a,r,l="de"){e.save(),e.beginPath(),e.ellipse(t,n,a,r,0,0,Math.PI*2),e.closePath(),e.setLineDash([20,10]),e.strokeStyle="rgba(100, 100, 100, 0.4)",e.lineWidth=3,e.stroke(),e.restore()}function Bt(e,t,n,a,r,l,i=1,s=0,o=0){e.save(),e.beginPath(),e.ellipse(n,a,r,l,0,0,Math.PI*2),e.closePath(),e.clip();const u=t.width/t.height,h=r/l,f=r*2,p=l*2;let m,y;u>h?(y=p,m=p*u):(m=f,y=f/u),m*=i,y*=i;const k=Math.max(0,(m-f)/2),d=Math.max(0,(y-p)/2),I=n-m/2+s*k,E=a-y/2+o*d;e.drawImage(t,I,E,m,y),e.restore()}function et(e,t,n,a="#2a3a2a"){e.save(),e.font=`${n.fontSize}px "Times New Roman", serif`,e.textAlign=n.align||"center",e.textBaseline="middle",e.fillStyle=a,n.maxWidth?e.fillText(t,n.x,n.y,n.maxWidth):e.fillText(t,n.x,n.y),e.restore()}function Nt(e,t,n,a="#2a3a2a"){e.save(),e.font=`${n.fontSize}px "Times New Roman", serif`,e.textAlign=n.align||"center",e.textBaseline="top",e.fillStyle=a;const r=n.maxWidth||400,l=n.lineHeight||n.fontSize*1.4,i=t.split(" "),s=[];let o="";for(const f of i){const p=o?`${o} ${f}`:f;e.measureText(p).width>r&&o?(s.push(o),o=f):o=p}o&&s.push(o);const u=s.length*l;let h=n.y-u/2;for(const f of s)e.fillText(f,n.x,h),h+=l;e.restore()}function jt(e,t,n,a,r,l="#2a3a2a"){e.save(),e.font=`${r.fontSize}px "Times New Roman", serif`,e.textAlign=r.align||"center",e.textBaseline="middle",e.fillStyle=l;const i=r.lineHeight||r.fontSize*1.8,s=[t,n,a].filter(Boolean),o=(s.length-1)*i;let u=r.y-o/2;for(const h of s)h&&(e.fillText(h,r.x,u),u+=i);e.restore()}function yn(e,t,n,a="#2a3a2a"){e.save(),e.strokeStyle=a,e.lineWidth=Math.max(2,t.labelFontSize/16),e.beginPath(),e.moveTo(t.x-t.width/2,t.y),e.lineTo(t.x+t.width/2,t.y),e.stroke(),e.font=`${t.labelFontSize}px "Times New Roman", serif`,e.textAlign="center",e.textBaseline="top",e.fillStyle=a,e.fillText(n,t.x,t.y+t.labelFontSize*.3),e.restore()}async function At(e,t,n,a,r,l,i,s,o,u=1,h=0,f=0,p=0,m=1,y="de"){const k=e.getContext("2d");if(!k)return;const d=document.createElement("canvas");d.width=s,d.height=o;const I=d.getContext("2d");if(!I)return;I.clearRect(0,0,s,o);const E=await Ct(t,p,s,o);ce(I,E,s,o);const v=await B(n);if(ce(I,v,s,o),r)try{const P=await B(r);Bt(I,P,i.portrait.x,i.portrait.y,i.portrait.radiusX,i.portrait.radiusY,u,h,f)}catch(P){console.error("Failed to load portrait:",P)}else wn(I,i.portrait.x,i.portrait.y,i.portrait.radiusX,i.portrait.radiusY,y);const S=await B(a);ce(I,S,s,o);const L=s/3633;Et(I,m,y,L),l&&et(I,l,i.namePlate),e.width=s,e.height=o,k.drawImage(d,0,0)}async function Dt(e,t,n,a,r,l,i,s,o,u,h,f=0,p=1,m="de"){const y=e.getContext("2d");if(!y)return;const k=document.createElement("canvas");k.width=u,k.height=h;const d=k.getContext("2d");if(!d)return;d.clearRect(0,0,u,h);const I=await Ct(t,f,u,h);ce(d,I,u,h);const E=await B(n);ce(d,E,u,h);const v=await B(a);ce(d,v,u,h);const S=u/3633;if(Et(d,p,m,S),o.contactInfo&&(r||l||i)&&jt(d,r,l,i,o.contactInfo),o.description&&s&&Nt(d,s,o.description),r&&et(d,r,o.namePlate),o.signature){const L=m==="de"?"Unterschrift":"Signature";yn(d,o.signature,L)}e.width=u,e.height=h,y.drawImage(k,0,0)}const Le="money-generator-portrait",Re="money-generator-bg-removed";async function vn(e){try{if(localStorage.removeItem(Le),!e)return;const t=await bt(e);try{localStorage.setItem(Le,t)}catch(n){console.warn("Could not persist portrait to localStorage:",n)}}catch(t){console.warn("Error processing portrait for storage:",t)}}async function kn(e){try{if(localStorage.removeItem(Re),!e)return;const t=await bt(e);try{localStorage.setItem(Re,t)}catch(n){console.warn("Could not persist bg-removed image to localStorage:",n)}}catch(t){console.warn("Error processing bg-removed image for storage:",t)}}function In(){try{return localStorage.getItem(Le)}catch{return null}}function Tn(){try{return localStorage.getItem(Re)}catch{return null}}function En(){try{localStorage.removeItem(Le),localStorage.removeItem(Re)}catch{}}function Sn(){return(typeof navigator<"u"?navigator.language:"de").toLowerCase().startsWith("de")?"de":"en"}const Ce=Sn(),ut={personalInfo:{name:"",email:"",phone:""},voucherConfig:{hours:1,description:"",language:Ce,templateHue:29},portrait:{original:null,enhanced:null,useEnhanced:!1,zoom:1,panX:0,panY:0,rawImage:null,bgRemovedImage:null,bgRemoved:!1,bgOpacity:0,bgBlur:0,engravingIntensity:0},currentSide:"front",isEnhancing:!1,isExporting:!1,appLanguage:Ce},w=nn.create()(an.persist(e=>({...ut,setPersonalInfo:t=>e(n=>({personalInfo:{...n.personalInfo,...t}})),setVoucherConfig:t=>e(n=>({voucherConfig:{...n.voucherConfig,...t}})),setPortrait:(t,n=null)=>(vn(t),e(a=>({portrait:{...a.portrait,original:t,enhanced:n,useEnhanced:!1,zoom:a.portrait.original&&t?a.portrait.zoom:1,panX:a.portrait.original&&t?a.portrait.panX:0,panY:a.portrait.original&&t?a.portrait.panY:0}}))),setEnhancedPortrait:t=>e(n=>({portrait:{...n.portrait,enhanced:t,useEnhanced:t!==null}})),toggleUseEnhanced:()=>e(t=>({portrait:{...t.portrait,useEnhanced:t.portrait.enhanced?!t.portrait.useEnhanced:!1}})),setPortraitZoom:t=>e(n=>({portrait:{...n.portrait,zoom:t}})),setPortraitPan:(t,n)=>e(a=>({portrait:{...a.portrait,panX:t,panY:n}})),setPortraitRawImage:t=>e(n=>({portrait:{...n.portrait,rawImage:t}})),setPortraitBgRemoved:(t,n)=>(n!==void 0&&kn(n),e(a=>({portrait:{...a.portrait,bgRemoved:t,bgRemovedImage:n!==void 0?n:a.portrait.bgRemovedImage}}))),setPortraitBgOpacity:t=>e(n=>({portrait:{...n.portrait,bgOpacity:t}})),setPortraitBgBlur:t=>e(n=>({portrait:{...n.portrait,bgBlur:t}})),setPortraitEngravingIntensity:t=>e(n=>({portrait:{...n.portrait,engravingIntensity:t}})),setCurrentSide:t=>e({currentSide:t}),flipSide:()=>e(t=>({currentSide:t.currentSide==="front"?"back":"front"})),setIsEnhancing:t=>e({isEnhancing:t}),setIsExporting:t=>e({isExporting:t}),setAppLanguage:t=>e({appLanguage:t}),setBillLanguage:t=>e(n=>({voucherConfig:{...n.voucherConfig,language:t}})),setHours:t=>e(n=>({voucherConfig:{...n.voucherConfig,hours:t}})),setTemplateHue:t=>(Rt(),Lt(),e(n=>({voucherConfig:{...n.voucherConfig,templateHue:t}}))),reset:()=>(En(),e(ut))}),{name:"money-generator-storage",migrate:e=>{const t=e;return t!=null&&t.voucherConfig&&(t.voucherConfig.templateHue===void 0&&(t.voucherConfig.templateHue=29),t.voucherConfig.hours=1,t.voucherConfig.language=Ce),t&&(t.appLanguage=Ce),t},version:2,partialize:e=>({personalInfo:e.personalInfo,voucherConfig:{...e.voucherConfig},appLanguage:e.appLanguage,portrait:{original:null,enhanced:null,useEnhanced:e.portrait.useEnhanced,zoom:e.portrait.zoom,panX:e.portrait.panX,panY:e.portrait.panY,rawImage:null,bgRemovedImage:null,bgRemoved:e.portrait.bgRemoved,bgOpacity:e.portrait.bgOpacity,bgBlur:e.portrait.bgBlur,engravingIntensity:e.portrait.engravingIntensity},currentSide:"front",isEnhancing:!1,isExporting:!1})}));if(typeof window<"u"){const e=In(),t=Tn();e&&setTimeout(()=>{const n=w.getState();if(!n.portrait.original){const a=n.portrait.bgRemoved,r=t!==null;w.setState({portrait:{...n.portrait,original:e,rawImage:e,bgRemovedImage:t,bgRemoved:a&&r,bgOpacity:a&&r?n.portrait.bgOpacity:0,bgBlur:a&&r?n.portrait.bgBlur:0}})}},0)}const Pn={header:{title:"Money Generator",subtitle:"Erstelle deinen persönlichen Zeitgutschein"},form:{personalInfo:{title:"Persönliche Daten",name:"Name",namePlaceholder:"Dein Name",email:"E-Mail",emailPlaceholder:"deine@email.de",phone:"Telefon",phonePlaceholder:"+49 123 456789"},portrait:{title:"Portrait",upload:"Bild hochladen",dragDrop:"oder hierher ziehen",enhance:"Mit AI verbessern",enhancing:"Wird verbessert...",useOriginal:"Original verwenden",useEnhanced:"Verbessertes verwenden",zoom:"Zoom"},voucher:{title:"Gutschein",hours:"Stunden",hourLabel:"Stunde",hoursLabel:"Stunden",description:"Beschreibung",descriptionPlaceholder:"Was kann mit diesem Gutschein eingelöst werden?",billLanguage:"Schein-Sprache",billLanguageGerman:"Deutsch",billLanguageEnglish:"Englisch"},billColor:{title:"Scheinfarbe",label:"Farbton"}},preview:{front:"Vorderseite",back:"Rückseite",flip:"Umdrehen"},export:{button:"Als PDF herunterladen",exporting:"PDF wird erstellt...",success:"Download gestartet!"},bill:{descriptionText:"Für diesen Schein erhältst du {bannerText} meiner Zeit oder ein gleichwertiges Dankeschön.",bannerText:{1:"eine Stunde",5:"fünf Stunden",10:"zehn Stunden"}}},Ln={header:{title:"Money Generator",subtitle:"Create your personal time voucher"},form:{personalInfo:{title:"Personal Information",name:"Name",namePlaceholder:"Your name",email:"Email",emailPlaceholder:"your@email.com",phone:"Phone",phonePlaceholder:"+1 234 567890"},portrait:{title:"Portrait",upload:"Upload image",dragDrop:"or drag and drop",enhance:"Enhance with AI",enhancing:"Enhancing...",useOriginal:"Use original",useEnhanced:"Use enhanced",zoom:"Zoom"},voucher:{title:"Voucher",hours:"Hours",hourLabel:"hour",hoursLabel:"hours",description:"Description",descriptionPlaceholder:"What can be redeemed with this voucher?",billLanguage:"Bill Language",billLanguageGerman:"German",billLanguageEnglish:"English"},billColor:{title:"Bill Color",label:"Hue"}},preview:{front:"Front",back:"Back",flip:"Flip"},export:{button:"Download as PDF",exporting:"Creating PDF...",success:"Download started!"},bill:{descriptionText:"For this voucher, you will receive {bannerText} of my time or an equivalent appreciation in return.",bannerText:{1:"one hour",5:"five hours",10:"ten hours"}}},Rn={de:Pn,en:Ln};function re(e){return Rn[e]}function tt(e,t,n){if(n&&n.trim())return n;const a=re(e),r=a.bill.bannerText[t]||a.bill.bannerText[1];return a.bill.descriptionText.replace("{bannerText}",r)}function Cn(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function Bn(e){return e.replace(/\D/g,"").length>=6}function Nn({focusField:e,onFocused:t,onFormFocusChange:n}={}){const a=w(d=>d.appLanguage),r=w(d=>d.personalInfo),l=w(d=>d.setPersonalInfo),i=re(a),[s,o]=g.useState(!1),[u,h]=g.useState(!1),f=s&&r.email.trim()&&!Cn(r.email),p=u&&r.phone.trim()&&!Bn(r.phone),m=g.useRef(null),y=g.useRef(null),k=g.useRef(null);return g.useEffect(()=>{if(e){const d=e==="name"?m:e==="email"?y:k;setTimeout(()=>{var I,E;(I=d.current)==null||I.click(),(E=d.current)==null||E.focus(),setTimeout(()=>{var v;(v=d.current)==null||v.scrollIntoView({behavior:"smooth",block:"center"})},300),t==null||t()},100)}},[e,t]),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"form-control",children:[c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text font-medium",children:i.form.personalInfo.name})}),c.jsx("input",{ref:m,type:"text",name:"name",autoComplete:"name",placeholder:i.form.personalInfo.namePlaceholder,className:"input input-bordered w-full input-md",value:r.name,onChange:d=>l({name:d.target.value}),onFocus:d=>{n==null||n(!0),setTimeout(()=>d.target.scrollIntoView({behavior:"smooth",block:"center"}),300)},onBlur:()=>n==null?void 0:n(!1)})]}),c.jsxs("div",{className:"form-control",children:[c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text font-medium",children:i.form.personalInfo.email})}),c.jsx("input",{ref:y,type:"email",name:"email",autoComplete:"email",placeholder:i.form.personalInfo.emailPlaceholder,className:`input input-bordered w-full input-md ${f?"input-error":""}`,value:r.email,onChange:d=>l({email:d.target.value}),onFocus:d=>{n==null||n(!0),setTimeout(()=>d.target.scrollIntoView({behavior:"smooth",block:"center"}),300)},onBlur:()=>{o(!0),n==null||n(!1)}}),f&&c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text-alt text-error",children:a==="de"?"Bitte gib eine gültige E-Mail-Adresse ein":"Please enter a valid email address"})})]}),c.jsxs("div",{className:"form-control",children:[c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text font-medium",children:i.form.personalInfo.phone})}),c.jsx("input",{ref:k,type:"tel",name:"phone",autoComplete:"tel",placeholder:i.form.personalInfo.phonePlaceholder,className:`input input-bordered w-full input-md ${p?"input-error":""}`,value:r.phone,onChange:d=>l({phone:d.target.value}),onFocus:d=>{n==null||n(!0),setTimeout(()=>d.target.scrollIntoView({behavior:"smooth",block:"center"}),300)},onBlur:()=>{h(!0),n==null||n(!1)}}),p&&c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text-alt text-error",children:a==="de"?"Bitte gib eine gültige Telefonnummer ein":"Please enter a valid phone number"})})]})]})}const $e={},jn="https://api.stability.ai/v1/generation",An="https://api.stability.ai/v2beta/stable-image/edit/remove-background",Ht="stability_api_key";let fe=null;function Dn(e){fe=e}function Hn(){return fe}function Mn(){return fe!==null}const Un={vintage:"portrait in the style of vintage currency engraving, fine line work, crosshatching, sepia tones, detailed stippling, classic bank note portrait style",engraved:"portrait as detailed intaglio engraving, currency bill style, fine parallel lines, high contrast, official government portrait",currency:"portrait rendered as US dollar bill engraving, official currency portrait style, green tint, fine line engraving technique"},dt=[{width:1024,height:1024},{width:1152,height:896},{width:1216,height:832},{width:1344,height:768},{width:1536,height:640},{width:640,height:1536},{width:768,height:1344},{width:832,height:1216},{width:896,height:1152}];function On(e,t){const n=e/t;let a=dt[0],r=1/0;for(const l of dt){const i=l.width/l.height,s=Math.abs(n-i);s<r&&(r=s,a=l)}return a}function Yn(e){return new Promise((t,n)=>{const a=new Image;a.onload=()=>{const r=On(a.width,a.height),l=document.createElement("canvas");l.width=r.width,l.height=r.height;const i=l.getContext("2d");if(!i){n(new Error("Failed to get canvas context"));return}const s=a.width/a.height,o=r.width/r.height;let u=0,h=0,f=a.width,p=a.height;s>o?(f=a.height*o,u=(a.width-f)/2):(p=a.width/o,h=(a.height-p)/2),i.drawImage(a,u,h,f,p,0,0,r.width,r.height),t(l.toDataURL("image/png"))},a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function Mt(e){var i;const t=e.split(","),n=((i=t[0].match(/:(.*?);/))==null?void 0:i[1])||"image/png",a=atob(t[1]),r=a.length,l=new Uint8Array(r);for(let s=0;s<r;s++)l[s]=a.charCodeAt(s);return new Blob([l],{type:n})}function je(){var t;const e=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ge&&ge.tagName.toUpperCase()==="SCRIPT"&&ge.src||new URL("index.cjs",document.baseURI).href}<"u"&&($e==null?void 0:$e.VITE_STABILITY_API_KEY)||typeof process<"u"&&((t=process.env)==null?void 0:t.NEXT_PUBLIC_STABILITY_API_KEY);return e&&e!=="your-api-key-here"?e:typeof localStorage<"u"?localStorage.getItem(Ht):null}function Ut(e){localStorage.setItem(Ht,e)}function Pe(){return fe?!0:je()!==null}async function _n(e){const t=je();if(!t)throw new Error("No Stability AI API key configured");const{imageDataUrl:n,style:a,strength:r=.35}=e,l=await Yn(n),i=Mt(l),s=new FormData;s.append("init_image",i,"portrait.png"),s.append("init_image_mode","IMAGE_STRENGTH"),s.append("image_strength",String(1-r)),s.append("text_prompts[0][text]",Un[a]),s.append("text_prompts[0][weight]","1"),s.append("cfg_scale","7"),s.append("samples","1"),s.append("steps","30");const u=await fetch(`${jn}/stable-diffusion-xl-1024-v1-0/image-to-image`,{method:"POST",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"},body:s});if(!u.ok){const f=await u.text();throw console.error("Stability AI error:",f),u.status===401?new Error("Invalid API key"):u.status===402?new Error("Insufficient credits"):u.status===429?new Error("Rate limit exceeded. Please try again later."):new Error(`API error: ${u.status}`)}const h=await u.json();if(!h.artifacts||h.artifacts.length===0)throw new Error("No image generated");return`data:image/png;base64,${h.artifacts[0].base64}`}async function Ot(e){if(fe){const i=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageDataUrl:e})});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.error||`API error: ${i.status}`)}return(await i.json()).imageDataUrl}const t=je();if(!t)throw new Error("No Stability AI API key configured");const n=Mt(e),a=new FormData;a.append("image",n,"image.png"),a.append("output_format","png");const r=await fetch(An,{method:"POST",headers:{Authorization:`Bearer ${t}`,Accept:"image/*"},body:a});if(!r.ok){const i=await r.text();throw console.error("Stability AI remove background error:",i),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}`)}const l=await r.blob();return new Promise((i,s)=>{const o=new FileReader;o.onload=()=>i(o.result),o.onerror=()=>s(new Error("Failed to read result")),o.readAsDataURL(l)})}function Wn(){const[e,t]=g.useState(!1),[n,a]=g.useState(!1),[r,l]=g.useState(null),[i,s]=g.useState(()=>Pe());g.useEffect(()=>{s(Pe());const p=setTimeout(()=>{s(Pe())},150);return()=>clearTimeout(p)},[]);const o=g.useCallback(()=>l(null),[]),u=g.useCallback(p=>{Ut(p),s(!0),l(null)},[]),h=g.useCallback(async(p,m=.5,y=40)=>{t(!0),l(null);try{return await xt(p,m,y)}catch(k){const d=k instanceof Error?k.message:"Enhancement failed";throw l(d),k}finally{t(!1)}},[]),f=g.useCallback(async p=>{a(!0),l(null);try{return await Ot(p)}catch(m){const y=m instanceof Error?m.message:"Background removal failed";throw l(y),m}finally{a(!1)}},[]);return{enhance:h,removeBg:f,isEnhancing:e,isRemovingBg:n,error:r,hasKey:i,setApiKey:u,clearError:o}}function Yt({isOpen:e,onClose:t,onSubmit:n}){const a=w(u=>u.appLanguage),[r,l]=g.useState("");if(!e)return null;const i=u=>{u.preventDefault(),r.trim()&&(n(r.trim()),l(""),t())},o={de:{title:"Stability AI API Key",description:"Um die AI-Bildverbesserung zu nutzen, benötigst du einen Stability AI API Key. Du kannst ihn auf platform.stability.ai erhalten.",placeholder:"sk-...",submit:"Speichern",cancel:"Abbrechen",hint:"Der Key wird lokal in deinem Browser gespeichert."},en:{title:"Stability AI API Key",description:"To use AI image enhancement, you need a Stability AI API key. You can get one at platform.stability.ai.",placeholder:"sk-...",submit:"Save",cancel:"Cancel",hint:"The key is stored locally in your browser."}}[a];return c.jsxs("dialog",{className:"modal modal-open",children:[c.jsxs("div",{className:"modal-box",children:[c.jsx("h3",{className:"font-bold text-lg",children:o.title}),c.jsx("p",{className:"py-4 text-sm opacity-80",children:o.description}),c.jsxs("form",{onSubmit:i,children:[c.jsxs("div",{className:"form-control",children:[c.jsx("input",{type:"password",placeholder:o.placeholder,className:"input input-bordered w-full",value:r,onChange:u=>l(u.target.value),autoFocus:!0}),c.jsx("label",{className:"label",children:c.jsx("span",{className:"label-text-alt",children:o.hint})})]}),c.jsxs("div",{className:"modal-action",children:[c.jsx("button",{type:"button",className:"btn btn-ghost",onClick:t,children:o.cancel}),c.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!r.trim(),children:o.submit})]})]})]}),c.jsx("form",{method:"dialog",className:"modal-backdrop",children:c.jsx("button",{onClick:t,children:"close"})})]})}function ye({min:e,max:t,step:n,value:a,onChange:r,className:l="",disabled:i=!1}){const s=g.useRef(null),o=g.useRef(null),u=g.useRef(!1),[h,f]=g.useState(!1),p=(a-e)/(t-e)*100,m=g.useCallback(v=>{if(!s.current)return a;const S=s.current.getBoundingClientRect(),L=Math.max(0,Math.min(1,(v-S.left)/S.width)),P=t-e,D=e+L*P,j=Math.round(D/n)*n;return Math.max(e,Math.min(t,j))},[e,t,n,a]),y=g.useCallback(v=>{if(i)return;const S=v.touches[0];o.current={x:S.clientX,y:S.clientY,value:a,decided:!1},u.current=!1},[a,i]),k=g.useCallback(v=>{if(i||!o.current)return;const S=v.touches[0],L=Math.abs(S.clientX-o.current.x),P=Math.abs(S.clientY-o.current.y);if(!o.current.decided){if(L<8&&P<8)return;if(o.current.decided=!0,P>L){o.current=null;return}u.current=!0,f(!0)}if(u.current){const D=m(S.clientX);D!==a&&r(D)}},[i,m,r,a]),d=g.useCallback(v=>{if(o.current&&!o.current.decided){const S=v.changedTouches[0];if(S){const L=m(S.clientX);L!==a&&r(L)}}o.current=null,u.current=!1,f(!1)},[m,r,a]);g.useEffect(()=>{const v=s.current;if(!v)return;const S=L=>{u.current&&L.preventDefault()};return v.addEventListener("touchmove",S,{passive:!1}),()=>{v.removeEventListener("touchmove",S)}},[]);const I=g.useCallback(v=>{if(i)return;const S=m(v.clientX);r(S),f(!0);const L=D=>{const j=m(D.clientX);r(j)},P=()=>{f(!1),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",L),document.addEventListener("mouseup",P)},[i,m,r]),E=`calc(10px + (100% - 20px) * ${p/100})`;return c.jsxs("div",{ref:s,className:`relative h-10 flex items-center cursor-pointer overflow-visible ${i?"opacity-50 cursor-not-allowed":""}`,onTouchStart:y,onTouchMove:k,onTouchEnd:d,onMouseDown:I,children:[c.jsx("div",{className:"absolute h-2 bg-base-300 rounded-full inset-x-0"}),c.jsx("div",{className:`absolute h-2 rounded-full transition-colors ${l.includes("range-primary")?"bg-primary":l.includes("range-secondary")?"bg-secondary":"bg-primary"}`,style:{left:0,width:E}}),c.jsx("div",{className:`absolute w-5 h-5 rounded-full bg-base-100 border-2 shadow-md transition-transform ${h?"scale-110":""} ${l.includes("range-primary")?"border-primary":l.includes("range-secondary")?"border-secondary":"border-primary"}`,style:{left:E,transform:"translateX(-50%)"}})]})}function zn(){const e=w(b=>b.appLanguage),t=w(b=>b.portrait),n=w(b=>b.setPortrait),a=w(b=>b.setPortraitZoom),r=w(b=>b.setPortraitPan),l=w(b=>b.setPortraitRawImage),i=w(b=>b.setPortraitBgRemoved),s=w(b=>b.setPortraitBgOpacity),o=w(b=>b.setPortraitBgBlur),u=w(b=>b.setPortraitEngravingIntensity),{enhance:h,removeBg:f,isEnhancing:p,isRemovingBg:m,error:y,hasKey:k,setApiKey:d}=Wn(),I=re(e),E=g.useRef(null),[v,S]=g.useState(!1),[L,P]=g.useState(!1),D=g.useRef(null),j=g.useRef(null),R=t.rawImage,C=t.bgRemovedImage,Y=t.bgRemoved,q=t.bgOpacity,H=t.bgBlur,O=t.engravingIntensity;g.useEffect(()=>{t.original&&!t.rawImage&&l(t.original)},[t.original,t.rawImage,l]),g.useEffect(()=>()=>{D.current&&clearTimeout(D.current),j.current&&clearTimeout(j.current)},[]);const Z=w(b=>b.voucherConfig.templateHue),oe=g.useRef(Z),J=g.useCallback(async b=>{if(!b.type.startsWith("image/"))return;const T=new FileReader;T.onload=async M=>{var _;const A=(_=M.target)==null?void 0:_.result,V=await ft(A);pt(),l(V),n(V),a(1),r(0,0),i(!1,null),s(0),o(0),u(0)},T.readAsDataURL(b)},[n,l,a,r,i,s,o,u]),be=g.useCallback(b=>{b.preventDefault(),S(!1);const T=b.dataTransfer.files[0];T&&J(T)},[J]),G=g.useCallback(b=>{b.preventDefault(),S(!0)},[]),Q=g.useCallback(b=>{b.preventDefault(),S(!1)},[]),K=()=>{var b;(b=E.current)==null||b.click()},xe=b=>{var M;const T=(M=b.target.files)==null?void 0:M[0];T&&J(T)},ee=g.useCallback(async(b,T,M)=>{try{return await h(b,T,M)}catch(A){return console.error("Enhancement failed:",A),b}},[h]),ve=g.useCallback(async b=>{try{const T=await f(b);return i(!0,T),T}catch(T){return console.error("Background removal failed:",T),b}},[f,i]),te=g.useCallback(async()=>{const b=w.getState(),T=b.portrait,M=b.voucherConfig.templateHue;if(!T.rawImage)return;let A;T.bgRemoved&&T.bgRemovedImage?A=await ze(T.bgRemovedImage,T.rawImage,T.bgOpacity,T.bgBlur):A=T.rawImage,T.engravingIntensity>0&&(A=await ee(A,T.engravingIntensity,M)),n(A)},[ee,n]);g.useEffect(()=>{if(oe.current===Z)return;oe.current=Z;const b=w.getState().portrait;b.engravingIntensity>0&&b.rawImage&&(D.current&&clearTimeout(D.current),D.current=setTimeout(te,150))},[Z,te]);const He=async()=>{if(!R)return;if(!Y&&!k){P(!0);return}if(!Y){const T=await ve(R),M=w.getState(),A=M.portrait,V=M.voucherConfig.templateHue;let _=await ze(T,R,A.bgOpacity,A.bgBlur);A.engravingIntensity>0&&(_=await ee(_,A.engravingIntensity,V)),n(_)}else{i(!1,null);const T=w.getState(),M=T.portrait.engravingIntensity,A=T.voucherConfig.templateHue;if(M>0){const V=await ee(R,M,A);n(V)}else n(R)}},we=b=>{u(b),D.current&&clearTimeout(D.current),R&&(D.current=setTimeout(te,150))},Me=async b=>{if(d(b),!R)return;const T=await ve(R),M=w.getState(),A=M.portrait,V=M.voucherConfig.templateHue;let _=await ze(T,R,A.bgOpacity,A.bgBlur);A.engravingIntensity>0&&(_=await ee(_,A.engravingIntensity,V)),n(_)},ke=b=>{s(b),j.current&&clearTimeout(j.current),!(!R||!C)&&(j.current=setTimeout(te,150))},Ie=b=>{o(b),j.current&&clearTimeout(j.current),!(!R||!C)&&(j.current=setTimeout(te,150))};return c.jsxs("div",{className:"space-y-4",children:[c.jsx("style",{children:`
|
|
2
2
|
@keyframes sparkle1 {
|
|
3
3
|
0%, 33%, 100% { opacity: 0.3; }
|
|
4
4
|
16% { opacity: 1; }
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
0%, 66%, 100% { opacity: 0.3; }
|
|
12
12
|
83% { opacity: 1; }
|
|
13
13
|
}
|
|
14
|
-
`}),t.original?c.jsxs("div",{className:"flex flex-col space-y-4",children:[c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full",children:[c.jsxs("div",{className:"form-control w-full",children:[c.jsxs("label",{className:"label",children:[c.jsx("span",{className:"label-text",children:I.form.portrait.zoom}),c.jsxs("span",{className:"label-text-alt",children:[Math.round(t.zoom*100),"%"]})]}),c.jsx(ye,{min:.5,max:2,step:.05,value:t.zoom,onChange:a,className:"range range-primary range-sm"})]}),c.jsxs("div",{className:"form-control w-full",children:[c.jsxs("label",{className:"label",children:[c.jsxs("span",{className:"label-text flex items-center gap-2",children:[e==="de"?"Farbanpassung":"Color adjustment",p&&c.jsx("span",{className:"loading loading-spinner loading-xs"})]}),c.jsxs("span",{className:"label-text-alt",children:[Math.round(O*100),"%"]})]}),c.jsx(ye,{min:0,max:1,step:.05,value:O,onChange:we,className:"range range-secondary range-sm",disabled:p||!R})]})]}),Y?c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full",children:[c.jsxs("div",{className:"form-control w-full",children:[c.jsxs("label",{className:"label",children:[c.jsx("span",{className:"label-text",children:e==="de"?"Hintergrund":"Background"}),c.jsxs("span",{className:"label-text-alt",children:[Math.round(q*100),"%"]})]}),c.jsx(ye,{min:0,max:1,step:.05,value:q,onChange:ke,className:"range range-primary range-sm"})]}),c.jsxs("div",{className:"form-control w-full",children:[c.jsxs("label",{className:"label",children:[c.jsx("span",{className:"label-text",children:e==="de"?"Unschärfe":"Blur"}),c.jsxs("span",{className:"label-text-alt",children:[Math.round(H*100),"%"]})]}),c.jsx(ye,{min:0,max:1,step:.05,value:H,onChange:Ie,className:"range range-primary range-sm",disabled:q===0})]})]}):c.jsx("div",{className:"flex justify-center",children:c.jsxs("button",{className:"btn btn-ghost btn gap-2 text-base-content/70",onClick:He,disabled:m||!R,children:[c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z",style:m?{animation:"sparkle1 2.4s ease-in-out infinite"}:void 0}),c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456z",style:m?{animation:"sparkle2 2.4s ease-in-out infinite"}:void 0}),c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z",style:m?{animation:"sparkle3 2.4s ease-in-out infinite"}:void 0})]}),m?e==="de"?"Hintergrund wird entfernt ...":"Removing background ...":e==="de"?"Hintergrund entfernen":"Remove background",!m&&!k&&c.jsx("span",{className:"badge badge-sm badge-outline",children:"API"})]})}),y&&c.jsxs("div",{className:"alert alert-warning text-sm py-2",children:[c.jsx("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:c.jsx("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"})}),c.jsx("span",{children:y})]})]}):c.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${m?"border-primary bg-primary/10 pointer-events-none":v?"border-primary bg-primary/10":"border-base-300 hover:border-primary hover:bg-base-200"}`,onDrop:be,onDragOver:G,onDragLeave:Q,onClick:K,children:[c.jsx("input",{ref:E,type:"file",accept:"image/*",className:"hidden",onChange:xe}),m?c.jsxs("div",{className:"flex flex-col items-center gap-2",children:[c.jsx("span",{className:"loading loading-spinner loading-lg text-primary"}),c.jsx("p",{className:"font-medium",children:e==="de"?"Hintergrund wird entfernt ...":"Removing background ..."})]}):c.jsxs("div",{className:"flex flex-col items-center gap-2",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-12 w-12 text-base-content/50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),c.jsx("p",{className:"font-medium",children:I.form.portrait.upload}),c.jsx("p",{className:"text-sm text-base-content/60",children:I.form.portrait.dragDrop})]})]}),c.jsx(Ot,{isOpen:L,onClose:()=>P(!1),onSubmit:Me})]})}function $n(){const e=w(s=>s.appLanguage),t=w(s=>s.voucherConfig.language),n=w(s=>s.voucherConfig.hours);w(s=>s.voucherConfig.templateHue);const a=w(s=>s.setBillLanguage),r=w(s=>s.setHours);w(s=>s.setTemplateHue);const l=re(e),i=[1,5,10];return c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"form-control",children:c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"label-text font-medium",children:l.form.voucher.billLanguage}),c.jsxs("div",{className:"join border border-base-300 rounded-lg shadow",children:[c.jsx("button",{className:`join-item btn btn-md ${t==="de"?"btn-primary":"btn-ghost"}`,onClick:()=>a("de"),children:l.form.voucher.billLanguageGerman}),c.jsx("button",{className:`join-item btn btn-md ${t==="en"?"btn-primary":"btn-ghost"}`,onClick:()=>a("en"),children:l.form.voucher.billLanguageEnglish})]})]})}),c.jsx("div",{className:"form-control",children:c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"label-text font-medium",children:l.form.voucher.hours}),c.jsx("div",{className:"join border border-base-300 rounded-lg shadow",children:i.map(s=>c.jsxs("button",{className:`join-item btn btn-md ${n===s?"btn-primary":"btn-ghost"}`,onClick:()=>r(s),children:[s,c.jsxs("span",{className:"hidden sm:inline",children:[" ",s===1?l.form.voucher.hourLabel:l.form.voucher.hoursLabel]})]},s))})]})}),!1]})}function nt(e,t){return{front:"",back:"",width:ne,height:ae}}const Ae={front:{portrait:{x:1810,y:918,radiusX:570,radiusY:605},namePlate:{x:1816,y:1765,fontSize:85,maxWidth:898,align:"center"}},back:{portrait:{x:0,y:0,radiusX:0,radiusY:0},namePlate:{x:1816,y:1770,fontSize:85,maxWidth:898,align:"center"},contactInfo:{x:898,y:939,fontSize:93,lineHeight:165,align:"center"},description:{x:2721,y:939,fontSize:85,maxWidth:1177,lineHeight:124,align:"center"},signature:{x:1820,y:1445,width:950,height:145,labelFontSize:85}}},ue=Ae,de=Ae;function at(e){return Ae}const Je=.75;function Xn(e){const t=at(),n=Je,a=r=>({portrait:{x:r.portrait.x*n,y:r.portrait.y*n,radiusX:r.portrait.radiusX*n,radiusY:r.portrait.radiusY*n},namePlate:{x:r.namePlate.x*n,y:r.namePlate.y*n,fontSize:r.namePlate.fontSize*n,maxWidth:r.namePlate.maxWidth?r.namePlate.maxWidth*n:void 0,lineHeight:r.namePlate.lineHeight?r.namePlate.lineHeight*n:void 0,align:r.namePlate.align},contactInfo:r.contactInfo?{x:r.contactInfo.x*n,y:r.contactInfo.y*n,fontSize:r.contactInfo.fontSize*n,maxWidth:r.contactInfo.maxWidth?r.contactInfo.maxWidth*n:void 0,lineHeight:r.contactInfo.lineHeight?r.contactInfo.lineHeight*n:void 0,align:r.contactInfo.align}:void 0,description:r.description?{x:r.description.x*n,y:r.description.y*n,fontSize:r.description.fontSize*n,maxWidth:r.description.maxWidth?r.description.maxWidth*n:void 0,lineHeight:r.description.lineHeight?r.description.lineHeight*n:void 0,align:r.description.align}:void 0,signature:r.signature?{x:r.signature.x*n,y:r.signature.y*n,width:r.signature.width*n,height:r.signature.height*n,labelFontSize:r.signature.labelFontSize*n}:void 0});return{front:a(t.front),back:a(t.back)}}function Gn(e,t){const n=nt();return{...n,width:Math.round(n.width*Je),height:Math.round(n.height*Je)}}function Vn(e,t){const[n,a]=g.useState(e);return g.useEffect(()=>{const r=setTimeout(()=>a(e),t);return()=>clearTimeout(r)},[e,t]),n}function Kn({onPortraitClick:e,onFileDrop:t}={}){const n=w(x=>x.appLanguage),a=w(x=>x.voucherConfig.language),r=w(x=>x.voucherConfig.hours),l=w(x=>x.voucherConfig.description),i=w(x=>x.voucherConfig.templateHue),s=w(x=>x.personalInfo),o=w(x=>x.portrait),u=w(x=>x.currentSide),h=w(x=>x.flipSide),f=w(x=>x.setPortraitPan),p=Vn(i,150),m=re(n),y=g.useRef(null),k=g.useRef(null),d=g.useRef(null),[I,E]=g.useState(!1),[v,S]=g.useState(!1),[L,P]=g.useState(!1),[D,j]=g.useState(!1),R=g.useRef(null),C=g.useRef(null),Y=g.useRef(!1),q=g.useRef(0),H=Gn(),O=Xn(),Z=o.useEnhanced&&o.enhanced?o.enhanced:o.original,oe=tt(a,r,l),[J,be]=g.useState(""),[G,Q]=g.useState(""),[K,xe]=g.useState(""),[ee,ve]=g.useState(""),[te,He]=g.useState(""),[we,Me]=g.useState(""),[ke,Ie]=g.useState(!0);g.useEffect(()=>{let x=!0;Ie(!0);async function N(){const[U,z]=await Promise.all([Ze(r,a,"front"),Ze(r,a,"back")]);x&&(be(U.background),Q(U.badges),xe(U.frame),ve(z.background),He(z.badges),Me(z.frame),Ie(!1))}return N(),()=>{x=!1}},[r,a]),g.useEffect(()=>{!y.current||!J||!G||!K||jt(y.current,J,G,K,Z,s.name,O.front,H.width,H.height,o.zoom,o.panX,o.panY,p,r,a)},[H,J,G,K,Z,s.name,O,o.zoom,o.panX,o.panY,p,r,a]),g.useEffect(()=>{!k.current||!ee||!te||!we||At(k.current,ee,te,we,s.name,s.email,s.phone,oe,O.back,H.width,H.height,p,r,a)},[H,ee,te,we,s,oe,O,p,r,a]);const b=()=>{E(!I),h()};g.useEffect(()=>{E(u==="back")},[u]);const T=g.useCallback((x,N)=>{if(!d.current||u!=="front")return!1;const U=d.current.getBoundingClientRect(),z=U.width/H.width,Ue=U.height/H.height,Te=(x-U.left)/z,Oe=(N-U.top)/Ue,{x:Ye,y:_e,radiusX:We,radiusY:en}=O.front.portrait,it=(Te-Ye)/We,st=(Oe-_e)/en;return it*it+st*st<=1},[u,H.width,H.height,O.front.portrait]),M=5,A=g.useCallback((x,N)=>{o.original&&(S(!0),R.current={x,y:N,panX:o.panX,panY:o.panY})},[o.original,o.panX,o.panY]),V=g.useCallback((x,N)=>{if(!v||!R.current||!d.current)return;const U=performance.now();if(U-q.current<33)return;q.current=U;const z=d.current.getBoundingClientRect(),Te=4/Math.max(z.width,z.height)*o.zoom,Oe=(x-R.current.x)*Te,Ye=(N-R.current.y)*Te,_e=Math.max(-1,Math.min(1,R.current.panX+Oe)),We=Math.max(-1,Math.min(1,R.current.panY+Ye));f(_e,We)},[v,f,o.zoom]),_=g.useCallback(()=>{S(!1),R.current=null,C.current=null},[]),rt=g.useCallback(()=>{e&&e()},[e]),Xt=x=>{T(x.clientX,x.clientY)&&(x.preventDefault(),C.current={x:x.clientX,y:x.clientY},Y.current=!1)},Gt=x=>{if(P(T(x.clientX,x.clientY)),C.current&&o.original){const N=x.clientX-C.current.x,U=x.clientY-C.current.y;Math.sqrt(N*N+U*U)>M&&!v&&(Y.current=!0,A(C.current.x,C.current.y))}v&&V(x.clientX,x.clientY)},Vt=x=>{C.current&&!Y.current&&T(x.clientX,x.clientY)&&rt(),_()},Kt=()=>{_(),P(!1)},Ft=x=>{if(x.touches.length===1){const N=x.touches[0];T(N.clientX,N.clientY)&&(C.current={x:N.clientX,y:N.clientY},Y.current=!1)}},qt=x=>{if(x.touches.length===1&&C.current&&o.original){const N=x.touches[0],U=N.clientX-C.current.x,z=N.clientY-C.current.y;Math.sqrt(U*U+z*z)>M&&!v&&(Y.current=!0,A(C.current.x,C.current.y)),v&&V(N.clientX,N.clientY)}},Zt=()=>{C.current&&!Y.current&&T(C.current.x,C.current.y)&&rt(),_()},ot=g.useRef(!1);g.useEffect(()=>{ot.current=v},[v]),g.useEffect(()=>{const x=d.current;if(!x)return;const N=U=>{ot.current&&U.preventDefault()};return x.addEventListener("touchmove",N,{passive:!1}),()=>{x.removeEventListener("touchmove",N)}},[]);const Jt=u==="front"&&o.original,Qt=H.width/H.height;return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between items-center mb-6",children:[c.jsxs("div",{className:"join border border-base-300 rounded-lg",children:[c.jsx("button",{className:`join-item btn btn-md ${u==="front"?"btn-primary":"btn-ghost"}`,onClick:()=>u!=="front"&&b(),children:m.preview.front}),c.jsx("button",{className:`join-item btn btn-md ${u==="back"?"btn-primary":"btn-ghost"}`,onClick:()=>u!=="back"&&b(),children:m.preview.back})]}),c.jsxs("button",{className:"btn btn-ghost btn-md",onClick:b,children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),c.jsx("span",{className:"hidden sm:inline",children:m.preview.flip})]})]}),c.jsxs("div",{className:"relative w-full overflow-visible",style:{aspectRatio:Qt,perspective:"1500px"},children:[ke&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-base-300 rounded-lg z-10",children:c.jsx("span",{className:"loading loading-spinner loading-lg text-primary"})}),c.jsxs("div",{ref:d,className:`relative w-full h-full shadow-lg ${L&&Jt?v?"cursor-grabbing":"cursor-grab":""} ${ke?"opacity-0":"opacity-100"} transition-opacity duration-300`,style:{transformStyle:"preserve-3d",transition:"transform 0.6s ease-in-out, opacity 0.3s ease-in-out",transform:I?"rotateY(180deg)":"rotateY(0deg)"},onMouseDown:Xt,onMouseMove:Gt,onMouseUp:Vt,onMouseLeave:Kt,onTouchStart:Ft,onTouchMove:qt,onTouchEnd:Zt,onDragOver:x=>{x.preventDefault(),u==="front"&&j(!0)},onDragLeave:x=>{x.preventDefault(),j(!1)},onDrop:x=>{if(x.preventDefault(),j(!1),u==="front"&&t){const N=x.dataTransfer.files[0];N&&N.type.startsWith("image/")&&t(N)}},children:[c.jsx("canvas",{ref:y,className:"absolute inset-0 w-full h-full",style:{backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"}}),c.jsx("canvas",{ref:k,className:"absolute inset-0 w-full h-full",style:{backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden",transform:"rotateY(180deg)"}}),u==="front"&&!o.original&&c.jsx("div",{className:`absolute flex flex-col items-center justify-center transition-colors duration-300 ease-in-out pointer-events-none ${D?"bg-primary/20":"hover:bg-base-content/5"}`,style:{left:`${(O.front.portrait.x-O.front.portrait.radiusX)/H.width*100}%`,top:`${(O.front.portrait.y-O.front.portrait.radiusY)/H.height*100}%`,width:`${O.front.portrait.radiusX*2/H.width*100}%`,height:`${O.front.portrait.radiusY*2/H.height*100}%`,borderRadius:"50%",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},children:c.jsxs("button",{className:"btn btn-dash hover:btn-dash hover:border-base-content/60 flex flex-col items-center gap-0.5 sm:gap-1 h-auto py-1.5 px-2.5 sm:py-3 sm:px-4 bg-base-100/20 hover:bg-base-100/30",children:[c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-7 h-6 sm:w-10 sm:h-9 text-base-content/50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"8",r:"4"}),c.jsx("path",{d:"M4 21c0-4 4-6 8-6s8 2 8 6"})]}),c.jsx("span",{className:"text-[10px] sm:text-xs text-center leading-tight whitespace-pre-line",children:n==="de"?`Foto
|
|
14
|
+
`}),t.original?c.jsxs("div",{className:"flex flex-col space-y-4",children:[c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full",children:[c.jsxs("div",{className:"form-control w-full",children:[c.jsxs("label",{className:"label",children:[c.jsx("span",{className:"label-text",children:I.form.portrait.zoom}),c.jsxs("span",{className:"label-text-alt",children:[Math.round(t.zoom*100),"%"]})]}),c.jsx(ye,{min:.5,max:2,step:.05,value:t.zoom,onChange:a,className:"range range-primary range-sm"})]}),c.jsxs("div",{className:"form-control w-full",children:[c.jsxs("label",{className:"label",children:[c.jsxs("span",{className:"label-text flex items-center gap-2",children:[e==="de"?"Farbanpassung":"Color adjustment",p&&c.jsx("span",{className:"loading loading-spinner loading-xs"})]}),c.jsxs("span",{className:"label-text-alt",children:[Math.round(O*100),"%"]})]}),c.jsx(ye,{min:0,max:1,step:.05,value:O,onChange:we,className:"range range-secondary range-sm",disabled:p||!R})]})]}),Y?c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full",children:[c.jsxs("div",{className:"form-control w-full",children:[c.jsxs("label",{className:"label",children:[c.jsx("span",{className:"label-text",children:e==="de"?"Hintergrund":"Background"}),c.jsxs("span",{className:"label-text-alt",children:[Math.round(q*100),"%"]})]}),c.jsx(ye,{min:0,max:1,step:.05,value:q,onChange:ke,className:"range range-primary range-sm"})]}),c.jsxs("div",{className:"form-control w-full",children:[c.jsxs("label",{className:"label",children:[c.jsx("span",{className:"label-text",children:e==="de"?"Unschärfe":"Blur"}),c.jsxs("span",{className:"label-text-alt",children:[Math.round(H*100),"%"]})]}),c.jsx(ye,{min:0,max:1,step:.05,value:H,onChange:Ie,className:"range range-primary range-sm",disabled:q===0})]})]}):c.jsx("div",{className:"flex justify-center",children:c.jsxs("button",{className:"btn btn-ghost btn gap-2 text-base-content/70",onClick:He,disabled:m||!R,children:[c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z",style:m?{animation:"sparkle1 2.4s ease-in-out infinite"}:void 0}),c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456z",style:m?{animation:"sparkle2 2.4s ease-in-out infinite"}:void 0}),c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z",style:m?{animation:"sparkle3 2.4s ease-in-out infinite"}:void 0})]}),m?e==="de"?"Hintergrund wird entfernt ...":"Removing background ...":e==="de"?"Hintergrund entfernen":"Remove background",!m&&!k&&c.jsx("span",{className:"badge badge-sm badge-outline",children:"API"})]})}),y&&c.jsxs("div",{className:"alert alert-warning text-sm py-2",children:[c.jsx("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:c.jsx("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"})}),c.jsx("span",{children:y})]})]}):c.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${m?"border-primary bg-primary/10 pointer-events-none":v?"border-primary bg-primary/10":"border-base-300 hover:border-primary hover:bg-base-200"}`,onDrop:be,onDragOver:G,onDragLeave:Q,onClick:K,children:[c.jsx("input",{ref:E,type:"file",accept:"image/*",className:"hidden",onChange:xe}),m?c.jsxs("div",{className:"flex flex-col items-center gap-2",children:[c.jsx("span",{className:"loading loading-spinner loading-lg text-primary"}),c.jsx("p",{className:"font-medium",children:e==="de"?"Hintergrund wird entfernt ...":"Removing background ..."})]}):c.jsxs("div",{className:"flex flex-col items-center gap-2",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-12 w-12 text-base-content/50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),c.jsx("p",{className:"font-medium",children:I.form.portrait.upload}),c.jsx("p",{className:"text-sm text-base-content/60",children:I.form.portrait.dragDrop})]})]}),c.jsx(Yt,{isOpen:L,onClose:()=>P(!1),onSubmit:Me})]})}function $n(){const e=w(s=>s.appLanguage),t=w(s=>s.voucherConfig.language),n=w(s=>s.voucherConfig.hours);w(s=>s.voucherConfig.templateHue);const a=w(s=>s.setBillLanguage),r=w(s=>s.setHours);w(s=>s.setTemplateHue);const l=re(e),i=[1,5,10];return c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"form-control",children:c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"label-text font-medium",children:l.form.voucher.billLanguage}),c.jsxs("div",{className:"join border border-base-300 rounded-lg shadow",children:[c.jsx("button",{className:`join-item btn btn-md ${t==="de"?"btn-primary":"btn-ghost"}`,onClick:()=>a("de"),children:l.form.voucher.billLanguageGerman}),c.jsx("button",{className:`join-item btn btn-md ${t==="en"?"btn-primary":"btn-ghost"}`,onClick:()=>a("en"),children:l.form.voucher.billLanguageEnglish})]})]})}),c.jsx("div",{className:"form-control",children:c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"label-text font-medium",children:l.form.voucher.hours}),c.jsx("div",{className:"join border border-base-300 rounded-lg shadow",children:i.map(s=>c.jsxs("button",{className:`join-item btn btn-md ${n===s?"btn-primary":"btn-ghost"}`,onClick:()=>r(s),children:[s,c.jsxs("span",{className:"hidden sm:inline",children:[" ",s===1?l.form.voucher.hourLabel:l.form.voucher.hoursLabel]})]},s))})]})}),!1]})}function nt(e,t){return{front:"",back:"",width:ne,height:ae}}const Ae={front:{portrait:{x:1810,y:918,radiusX:570,radiusY:605},namePlate:{x:1816,y:1765,fontSize:85,maxWidth:898,align:"center"}},back:{portrait:{x:0,y:0,radiusX:0,radiusY:0},namePlate:{x:1816,y:1770,fontSize:85,maxWidth:898,align:"center"},contactInfo:{x:898,y:939,fontSize:93,lineHeight:165,align:"center"},description:{x:2721,y:939,fontSize:85,maxWidth:1177,lineHeight:124,align:"center"},signature:{x:1820,y:1445,width:950,height:145,labelFontSize:85}}},ue=Ae,de=Ae;function at(e){return Ae}const Je=.75;function Xn(e){const t=at(),n=Je,a=r=>({portrait:{x:r.portrait.x*n,y:r.portrait.y*n,radiusX:r.portrait.radiusX*n,radiusY:r.portrait.radiusY*n},namePlate:{x:r.namePlate.x*n,y:r.namePlate.y*n,fontSize:r.namePlate.fontSize*n,maxWidth:r.namePlate.maxWidth?r.namePlate.maxWidth*n:void 0,lineHeight:r.namePlate.lineHeight?r.namePlate.lineHeight*n:void 0,align:r.namePlate.align},contactInfo:r.contactInfo?{x:r.contactInfo.x*n,y:r.contactInfo.y*n,fontSize:r.contactInfo.fontSize*n,maxWidth:r.contactInfo.maxWidth?r.contactInfo.maxWidth*n:void 0,lineHeight:r.contactInfo.lineHeight?r.contactInfo.lineHeight*n:void 0,align:r.contactInfo.align}:void 0,description:r.description?{x:r.description.x*n,y:r.description.y*n,fontSize:r.description.fontSize*n,maxWidth:r.description.maxWidth?r.description.maxWidth*n:void 0,lineHeight:r.description.lineHeight?r.description.lineHeight*n:void 0,align:r.description.align}:void 0,signature:r.signature?{x:r.signature.x*n,y:r.signature.y*n,width:r.signature.width*n,height:r.signature.height*n,labelFontSize:r.signature.labelFontSize*n}:void 0});return{front:a(t.front),back:a(t.back)}}function Gn(e,t){const n=nt();return{...n,width:Math.round(n.width*Je),height:Math.round(n.height*Je)}}function Vn(e,t){const[n,a]=g.useState(e);return g.useEffect(()=>{const r=setTimeout(()=>a(e),t);return()=>clearTimeout(r)},[e,t]),n}function Kn({onPortraitClick:e,onFileDrop:t}={}){const n=w(x=>x.appLanguage),a=w(x=>x.voucherConfig.language),r=w(x=>x.voucherConfig.hours),l=w(x=>x.voucherConfig.description),i=w(x=>x.voucherConfig.templateHue),s=w(x=>x.personalInfo),o=w(x=>x.portrait),u=w(x=>x.currentSide),h=w(x=>x.flipSide),f=w(x=>x.setPortraitPan),p=Vn(i,150),m=re(n),y=g.useRef(null),k=g.useRef(null),d=g.useRef(null),[I,E]=g.useState(!1),[v,S]=g.useState(!1),[L,P]=g.useState(!1),[D,j]=g.useState(!1),R=g.useRef(null),C=g.useRef(null),Y=g.useRef(!1),q=g.useRef(0),H=Gn(),O=Xn(),Z=o.useEnhanced&&o.enhanced?o.enhanced:o.original,oe=tt(a,r,l),[J,be]=g.useState(""),[G,Q]=g.useState(""),[K,xe]=g.useState(""),[ee,ve]=g.useState(""),[te,He]=g.useState(""),[we,Me]=g.useState(""),[ke,Ie]=g.useState(!0);g.useEffect(()=>{let x=!0;Ie(!0);async function N(){const[U,z]=await Promise.all([Ze(r,a,"front"),Ze(r,a,"back")]);x&&(be(U.background),Q(U.badges),xe(U.frame),ve(z.background),He(z.badges),Me(z.frame),Ie(!1))}return N(),()=>{x=!1}},[r,a]),g.useEffect(()=>{!y.current||!J||!G||!K||At(y.current,J,G,K,Z,s.name,O.front,H.width,H.height,o.zoom,o.panX,o.panY,p,r,a)},[H,J,G,K,Z,s.name,O,o.zoom,o.panX,o.panY,p,r,a]),g.useEffect(()=>{!k.current||!ee||!te||!we||Dt(k.current,ee,te,we,s.name,s.email,s.phone,oe,O.back,H.width,H.height,p,r,a)},[H,ee,te,we,s,oe,O,p,r,a]);const b=()=>{E(!I),h()};g.useEffect(()=>{E(u==="back")},[u]);const T=g.useCallback((x,N)=>{if(!d.current||u!=="front")return!1;const U=d.current.getBoundingClientRect(),z=U.width/H.width,Ue=U.height/H.height,Te=(x-U.left)/z,Oe=(N-U.top)/Ue,{x:Ye,y:_e,radiusX:We,radiusY:tn}=O.front.portrait,it=(Te-Ye)/We,st=(Oe-_e)/tn;return it*it+st*st<=1},[u,H.width,H.height,O.front.portrait]),M=5,A=g.useCallback((x,N)=>{o.original&&(S(!0),R.current={x,y:N,panX:o.panX,panY:o.panY})},[o.original,o.panX,o.panY]),V=g.useCallback((x,N)=>{if(!v||!R.current||!d.current)return;const U=performance.now();if(U-q.current<33)return;q.current=U;const z=d.current.getBoundingClientRect(),Te=4/Math.max(z.width,z.height)*o.zoom,Oe=(x-R.current.x)*Te,Ye=(N-R.current.y)*Te,_e=Math.max(-1,Math.min(1,R.current.panX+Oe)),We=Math.max(-1,Math.min(1,R.current.panY+Ye));f(_e,We)},[v,f,o.zoom]),_=g.useCallback(()=>{S(!1),R.current=null,C.current=null},[]),rt=g.useCallback(()=>{e&&e()},[e]),Gt=x=>{T(x.clientX,x.clientY)&&(x.preventDefault(),C.current={x:x.clientX,y:x.clientY},Y.current=!1)},Vt=x=>{if(P(T(x.clientX,x.clientY)),C.current&&o.original){const N=x.clientX-C.current.x,U=x.clientY-C.current.y;Math.sqrt(N*N+U*U)>M&&!v&&(Y.current=!0,A(C.current.x,C.current.y))}v&&V(x.clientX,x.clientY)},Kt=x=>{C.current&&!Y.current&&T(x.clientX,x.clientY)&&rt(),_()},Ft=()=>{_(),P(!1)},qt=x=>{if(x.touches.length===1){const N=x.touches[0];T(N.clientX,N.clientY)&&(C.current={x:N.clientX,y:N.clientY},Y.current=!1)}},Zt=x=>{if(x.touches.length===1&&C.current&&o.original){const N=x.touches[0],U=N.clientX-C.current.x,z=N.clientY-C.current.y;Math.sqrt(U*U+z*z)>M&&!v&&(Y.current=!0,A(C.current.x,C.current.y)),v&&V(N.clientX,N.clientY)}},Jt=()=>{C.current&&!Y.current&&T(C.current.x,C.current.y)&&rt(),_()},ot=g.useRef(!1);g.useEffect(()=>{ot.current=v},[v]),g.useEffect(()=>{const x=d.current;if(!x)return;const N=U=>{ot.current&&U.preventDefault()};return x.addEventListener("touchmove",N,{passive:!1}),()=>{x.removeEventListener("touchmove",N)}},[]);const Qt=u==="front"&&o.original,en=H.width/H.height;return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex justify-between items-center mb-6",children:[c.jsxs("div",{className:"join border border-base-300 rounded-lg",children:[c.jsx("button",{className:`join-item btn btn-md ${u==="front"?"btn-primary":"btn-ghost"}`,onClick:()=>u!=="front"&&b(),children:m.preview.front}),c.jsx("button",{className:`join-item btn btn-md ${u==="back"?"btn-primary":"btn-ghost"}`,onClick:()=>u!=="back"&&b(),children:m.preview.back})]}),c.jsxs("button",{className:"btn btn-ghost btn-md",onClick:b,children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),c.jsx("span",{className:"hidden sm:inline",children:m.preview.flip})]})]}),c.jsxs("div",{className:"relative w-full overflow-visible",style:{aspectRatio:en,perspective:"1500px"},children:[ke&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-base-300 rounded-lg z-10",children:c.jsx("span",{className:"loading loading-spinner loading-lg text-primary"})}),c.jsxs("div",{ref:d,className:`relative w-full h-full shadow-lg ${L&&Qt?v?"cursor-grabbing":"cursor-grab":""} ${ke?"opacity-0":"opacity-100"} transition-opacity duration-300`,style:{transformStyle:"preserve-3d",transition:"transform 0.6s ease-in-out, opacity 0.3s ease-in-out",transform:I?"rotateY(180deg)":"rotateY(0deg)"},onMouseDown:Gt,onMouseMove:Vt,onMouseUp:Kt,onMouseLeave:Ft,onTouchStart:qt,onTouchMove:Zt,onTouchEnd:Jt,onDragOver:x=>{x.preventDefault(),u==="front"&&j(!0)},onDragLeave:x=>{x.preventDefault(),j(!1)},onDrop:x=>{if(x.preventDefault(),j(!1),u==="front"&&t){const N=x.dataTransfer.files[0];N&&N.type.startsWith("image/")&&t(N)}},children:[c.jsx("canvas",{ref:y,className:"absolute inset-0 w-full h-full",style:{backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"}}),c.jsx("canvas",{ref:k,className:"absolute inset-0 w-full h-full",style:{backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden",transform:"rotateY(180deg)"}}),u==="front"&&!o.original&&c.jsx("div",{className:`absolute flex flex-col items-center justify-center transition-colors duration-300 ease-in-out pointer-events-none ${D?"bg-primary/20":"hover:bg-base-content/5"}`,style:{left:`${(O.front.portrait.x-O.front.portrait.radiusX)/H.width*100}%`,top:`${(O.front.portrait.y-O.front.portrait.radiusY)/H.height*100}%`,width:`${O.front.portrait.radiusX*2/H.width*100}%`,height:`${O.front.portrait.radiusY*2/H.height*100}%`,borderRadius:"50%",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},children:c.jsxs("button",{className:"btn btn-dash hover:btn-dash hover:border-base-content/60 flex flex-col items-center gap-0.5 sm:gap-1 h-auto py-1.5 px-2.5 sm:py-3 sm:px-4 bg-base-100/20 hover:bg-base-100/30",children:[c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-7 h-6 sm:w-10 sm:h-9 text-base-content/50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"8",r:"4"}),c.jsx("path",{d:"M4 21c0-4 4-6 8-6s8 2 8 6"})]}),c.jsx("span",{className:"text-[10px] sm:text-xs text-center leading-tight whitespace-pre-line",children:n==="de"?`Foto
|
|
15
15
|
hochladen`:`Upload
|
|
16
16
|
photo`})]})})]})]})]})}function Fn(){const e=g.useRef(null),t=g.useRef(null);return{frontCanvasRef:e,backCanvasRef:t}}const qn=`
|
|
17
17
|
// Translations for banner text
|
|
@@ -488,4 +488,4 @@ self.onmessage = async (e) => {
|
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
490
|
};
|
|
491
|
-
`;let Xe=null,gt=null;function Zn(){if(!Xe){const e=new Blob([qn],{type:"application/javascript"});gt=URL.createObjectURL(e),Xe=new Worker(gt,{type:"module"})}return Xe}async function Ge(e){const n=await(await fetch(e)).blob();return URL.createObjectURL(n)}function mt(e,t){const n=new Uint8Array(e);let a="";for(let r=0;r<n.length;r++)a+=String.fromCharCode(n[r]);return`data:${t};base64,${btoa(a)}`}async function
|
|
491
|
+
`;let Xe=null,gt=null;function Zn(){if(!Xe){const e=new Blob([qn],{type:"application/javascript"});gt=URL.createObjectURL(e),Xe=new Worker(gt,{type:"module"})}return Xe}async function Ge(e){const n=await(await fetch(e)).blob();return URL.createObjectURL(n)}function mt(e,t){const n=new Uint8Array(e);let a="";for(let r=0;r<n.length;r++)a+=String.fromCharCode(n[r]);return`data:${t};base64,${btoa(a)}`}async function _t(e){const{frontTemplateSrc:t,backTemplateSrc:n,templateWidth:a,templateHeight:r,layout:l,portrait:i,portraitZoom:s=1,portraitPanX:o=0,portraitPanY:u=0,templateHue:h=160,name:f,email:p,phone:m,description:y,language:k="de",hours:d=1}=e,[I,E]=await Promise.all([Ge(t),Ge(n)]);let v=null;return i&&(v=await Ge(i)),new Promise((S,L)=>{const P=Zn(),D=setTimeout(()=>{P.removeEventListener("message",j),P.removeEventListener("error",R),URL.revokeObjectURL(I),URL.revokeObjectURL(E),v&&URL.revokeObjectURL(v),L(new Error("PDF generation timed out. Please try again."))},6e4),j=C=>{if(clearTimeout(D),P.removeEventListener("message",j),P.removeEventListener("error",R),URL.revokeObjectURL(I),URL.revokeObjectURL(E),v&&URL.revokeObjectURL(v),C.data.type==="success")try{const{frontImageData:Y,backImageData:q,width:H,height:O}=C.data;if(!Y||!q||!H||!O){L(new Error("Invalid response from worker"));return}const Z=mt(Y,"image/jpeg"),oe=mt(q,"image/jpeg"),J=138.6,be=72.9,G=J,Q=be,K=new rn.jsPDF({orientation:G>Q?"landscape":"portrait",unit:"mm",format:[G,Q]});K.addImage(Z,"JPEG",0,0,G,Q),K.addPage([G,Q]),K.addImage(oe,"JPEG",0,0,G,Q);const xe=K.output("blob");S(xe)}catch(Y){L(Y)}else L(new Error(C.data.error))},R=C=>{P.removeEventListener("message",j),P.removeEventListener("error",R),URL.revokeObjectURL(I),URL.revokeObjectURL(E),v&&URL.revokeObjectURL(v),L(new Error(C.message))};P.addEventListener("message",j),P.addEventListener("error",R),P.postMessage({type:"generate",frontTemplateUrl:I,backTemplateUrl:E,portraitUrl:v,templateWidth:a,templateHeight:r,templateHue:h,portraitZoom:s,portraitPanX:o,portraitPanY:u,layout:{front:{portrait:l.front.portrait,namePlate:l.front.namePlate},back:{namePlate:l.back.namePlate,contactInfo:l.back.contactInfo,description:l.back.description,signature:l.back.signature}},name:f,email:p,phone:m,description:y,language:k,hours:d})})}function Wt(e,t){const n=URL.createObjectURL(e),a=document.createElement("a");a.href=n,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)}async function zt(e){const t=await _t(e);Wt(t,e.filename)}function Jn(){const e=w(d=>d.appLanguage),t=w(d=>d.voucherConfig.language),n=w(d=>d.voucherConfig.hours),a=w(d=>d.voucherConfig.description),r=w(d=>d.voucherConfig.templateHue),l=w(d=>d.personalInfo),i=w(d=>d.portrait),s=w(d=>d.isExporting),o=w(d=>d.setIsExporting),u=re(e),h=nt(),f=at(),p=i.useEnhanced&&i.enhanced?i.enhanced:i.original,m=tt(t,n,a),y=l.name.trim().length>0&&l.email.trim().length>0&&l.phone.trim().length>0&&i.original!==null,k=async()=>{if(!(!y||s)){o(!0);try{const[d,I]=await Promise.all([qe(n,t,"front"),qe(n,t,"back")]),E=`zeitgutschein-${n}h-${l.name.replace(/\s+/g,"-").toLowerCase()}.pdf`;await zt({frontTemplateSrc:d,backTemplateSrc:I,templateWidth:h.width,templateHeight:h.height,layout:f,portrait:p,portraitZoom:i.zoom,portraitPanX:i.panX,portraitPanY:i.panY,templateHue:r,name:l.name,email:l.email,phone:l.phone,description:m,filename:E,language:t,hours:n})}catch(d){console.error("PDF export failed:",d)}finally{o(!1)}}};return c.jsxs("button",{className:`btn btn-primary w-full btn-md ${y?"":"btn-disabled"}`,onClick:k,disabled:!y,"aria-busy":s,children:[s?c.jsx("span",{className:"loading loading-spinner loading-sm"}):c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),u.export.button]})}function $t(){const e=w(a=>a.appLanguage),t=w(a=>a.setAppLanguage),n=a=>{t(a)};return c.jsxs("div",{className:"join",children:[c.jsx("button",{className:`join-item btn btn-sm ${e==="de"?"btn-primary":"btn-ghost"}`,onClick:()=>n("de"),children:"DE"}),c.jsx("button",{className:`join-item btn btn-sm ${e==="en"?"btn-primary":"btn-ghost"}`,onClick:()=>n("en"),children:"EN"})]})}function Qn(){const e=w(n=>n.appLanguage),t=re(e);return c.jsxs("div",{className:"navbar bg-currency-green text-currency-cream shadow-lg shrink-0",children:[c.jsx("div",{className:"navbar-start",children:c.jsx("a",{className:"btn btn-ghost text-xl font-currency font-bold",children:t.header.title})}),c.jsx("div",{className:"navbar-center hidden sm:flex",children:c.jsx("span",{className:"text-sm opacity-80",children:t.header.subtitle})}),c.jsx("div",{className:"navbar-end",children:c.jsx($t,{})})]})}const Be="/",ea={id:"time-voucher-classic-de",name:"Zeitgutschein Classic",type:"time-voucher",category:"classic",images:{front:`${Be}templates/front_hdpi_de.jpg`,back:`${Be}templates/back_hdpi_de.jpg`,width:6144,height:4096},fields:[{id:"name",type:"text",label:{de:"Name",en:"Name"},required:!0,validation:{minLength:1,maxLength:50}},{id:"hours",type:"select",label:{de:"Stunden",en:"Hours"},required:!0,options:["1","5","10"]},{id:"portrait",type:"image",label:{de:"Portrait",en:"Portrait"},required:!1},{id:"email",type:"text",label:{de:"E-Mail",en:"Email"},required:!1},{id:"phone",type:"text",label:{de:"Telefon",en:"Phone"},required:!1},{id:"description",type:"textarea",label:{de:"Beschreibung",en:"Description"},required:!1,validation:{maxLength:200}}],layout:{front:{portrait:ue.front.portrait,name:ue.front.namePlate},back:{name:ue.back.namePlate,contactInfo:ue.back.contactInfo,description:ue.back.description}},languages:["de"]},ta={id:"time-voucher-classic-en",name:"Time Voucher Classic",type:"time-voucher",category:"classic",images:{front:`${Be}templates/front_ldpi_en.png`,back:`${Be}templates/back_ldpi_en.png`,width:1536,height:1024},fields:[{id:"name",type:"text",label:{de:"Name",en:"Name"},required:!0,validation:{minLength:1,maxLength:50}},{id:"hours",type:"select",label:{de:"Stunden",en:"Hours"},required:!0,options:["1","5","10"]},{id:"portrait",type:"image",label:{de:"Portrait",en:"Portrait"},required:!1},{id:"email",type:"text",label:{de:"E-Mail",en:"Email"},required:!1},{id:"phone",type:"text",label:{de:"Telefon",en:"Phone"},required:!1},{id:"description",type:"textarea",label:{de:"Beschreibung",en:"Description"},required:!1,validation:{maxLength:200}}],layout:{front:{portrait:de.front.portrait,name:de.front.namePlate},back:{name:de.back.namePlate,contactInfo:de.back.contactInfo,description:de.back.description}},languages:["en"]},ht=[ea,ta],Xt={async listTemplates(e){let t=[...ht];return e!=null&&e.type&&(t=t.filter(n=>n.type===e.type)),e!=null&&e.category&&(t=t.filter(n=>n.category===e.category)),e!=null&&e.language&&(t=t.filter(n=>n.languages.includes(e.language))),t},async getTemplate(e){const t=ht.find(n=>n.id===e);if(!t)throw new Error(`Template not found: ${e}`);return t}};function na(e){return e==="de"?"time-voucher-classic-de":"time-voucher-classic-en"}let De=Xt;function aa(e){De=e}function ra(){return De}async function oa(e){return De.listTemplates(e)}async function ia(e){return De.getTemplate(e)}exports.ApiKeyModal=Yt;exports.BillPreview=Kn;exports.ExportButton=Jn;exports.Header=Qn;exports.LAYOUT_HDPI=ue;exports.LAYOUT_LDPI=de;exports.LanguageToggle=$t;exports.PREVIEW_HEIGHT=dn;exports.PREVIEW_WIDTH=un;exports.PersonalInfoForm=Nn;exports.PortraitUpload=zn;exports.TEMPLATE_HEIGHT=ae;exports.TEMPLATE_LAYOUT=Ae;exports.TEMPLATE_WIDTH=ne;exports.TouchSlider=ye;exports.VoucherConfig=$n;exports.applyEngravingEffect=xt;exports.applyHueShift=yt;exports.clearCompositorCache=Lt;exports.clearHueShiftedCache=Rt;exports.composeTemplate=Pt;exports.composeTemplateFullRes=qe;exports.downloadBlob=Wt;exports.drawContactInfo=jt;exports.drawMultilineText=Nt;exports.drawOvalPortrait=Bt;exports.drawTemplate=ce;exports.drawText=et;exports.enhancePortrait=_n;exports.exportBillAsPDF=zt;exports.formatDescription=tt;exports.generateBillPDF=_t;exports.getApiKey=je;exports.getDefaultTemplateId=na;exports.getLayout=at;exports.getRemoveBackgroundEndpoint=Hn;exports.getTemplate=nt;exports.getTemplateById=ia;exports.getTemplateDimensions=pn;exports.getTemplateLayers=Ze;exports.getTemplateProvider=ra;exports.hasApiKey=Pe;exports.hasCustomEndpoint=Mn;exports.listTemplates=oa;exports.loadImage=B;exports.preloadAllTemplates=fn;exports.preloadBaseImages=gn;exports.removeBackground=Ot;exports.renderBackSide=Dt;exports.renderFrontSide=At;exports.resizeImage=ft;exports.setApiKey=Ut;exports.setRemoveBackgroundEndpoint=Dn;exports.setTemplateProvider=aa;exports.staticTemplateProvider=Xt;exports.t=re;exports.useBillCanvasRefs=Fn;exports.useBillStore=w;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as v, jsx as u } from "react/jsx-runtime";
|
|
2
2
|
import { useState as H, useRef as W, useEffect as j, useCallback as O } from "react";
|
|
3
|
-
import { create as
|
|
4
|
-
import { persist as
|
|
5
|
-
import { jsPDF as
|
|
6
|
-
const
|
|
3
|
+
import { create as Wt } from "zustand";
|
|
4
|
+
import { persist as zt } from "zustand/middleware";
|
|
5
|
+
import { jsPDF as _t } from "jspdf";
|
|
6
|
+
const $t = 1024, ot = 1200, ge = /* @__PURE__ */ new Map();
|
|
7
7
|
let Q = null, it = null;
|
|
8
8
|
function Je(e, t) {
|
|
9
9
|
return Q || (Q = document.createElement("canvas"), it = Q.getContext("2d", { willReadFrequently: !0 })), (Q.width !== e || Q.height !== t) && (Q.width = e, Q.height = t), it;
|
|
@@ -21,10 +21,10 @@ function fe(e) {
|
|
|
21
21
|
}, r.onerror = () => a(new Error("Failed to load image")), r.src = e;
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function ht() {
|
|
25
25
|
ge.clear();
|
|
26
26
|
}
|
|
27
|
-
async function Xt(e, t =
|
|
27
|
+
async function Xt(e, t = $t) {
|
|
28
28
|
const n = await fe(e), a = Math.max(n.width, n.height);
|
|
29
29
|
if (a <= t)
|
|
30
30
|
return e;
|
|
@@ -32,7 +32,7 @@ async function Xt(e, t = _t) {
|
|
|
32
32
|
if (!o) throw new Error("Failed to get canvas context");
|
|
33
33
|
return s.width = c, s.height = i, o.drawImage(n, 0, 0, c, i), s.toDataURL("image/jpeg", 0.9);
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
35
|
+
async function pt(e) {
|
|
36
36
|
const t = await fe(e), n = Math.max(t.width, t.height);
|
|
37
37
|
if (n <= ot) {
|
|
38
38
|
const o = document.createElement("canvas"), l = o.getContext("2d");
|
|
@@ -63,7 +63,7 @@ async function jt(e, t = 0.5, n = 40) {
|
|
|
63
63
|
if (d === 0) continue;
|
|
64
64
|
let E = (((77 * g + 150 * w + 29 * I >> 8) / 255 - 0.5) * o + 0.5) * 255;
|
|
65
65
|
E < 0 ? E = 0 : E > 255 && (E = 255);
|
|
66
|
-
const x = E / 255, P = 0.12, [L, S, D] =
|
|
66
|
+
const x = E / 255, P = 0.12, [L, S, D] = ft(m, P, x), A = g * l + L * t | 0, R = w * l + S * t | 0, N = I * l + D * t | 0;
|
|
67
67
|
s[p] = d << 24 | N << 16 | R << 8 | A;
|
|
68
68
|
}
|
|
69
69
|
return r.putImageData(c, 0, 0), Q.toDataURL("image/png");
|
|
@@ -88,7 +88,7 @@ function Gt(e, t, n) {
|
|
|
88
88
|
}
|
|
89
89
|
return [i, s, c];
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function ft(e, t, n) {
|
|
92
92
|
if (t === 0) {
|
|
93
93
|
const i = Math.round(n * 255);
|
|
94
94
|
return [i, i, i];
|
|
@@ -112,7 +112,7 @@ async function Ft(e, t) {
|
|
|
112
112
|
if (d === 0) continue;
|
|
113
113
|
const [k, E, x] = Gt(g, w, I);
|
|
114
114
|
if (E < 0.08 || k < o || k > l) continue;
|
|
115
|
-
const P = s, L = Math.min(E, 0.05), [S, D, A] =
|
|
115
|
+
const P = s, L = Math.min(E, 0.05), [S, D, A] = ft(P, L, x);
|
|
116
116
|
i[p] = d << 24 | A << 16 | D << 8 | S;
|
|
117
117
|
}
|
|
118
118
|
return a.putImageData(r, 0, 0), Q.toDataURL("image/png");
|
|
@@ -125,7 +125,7 @@ const me = typeof import.meta < "u" && "/" || "/", F = {
|
|
|
125
125
|
1: `${me}templates/1.png`,
|
|
126
126
|
5: `${me}templates/5.png`,
|
|
127
127
|
10: `${me}templates/10.png`
|
|
128
|
-
},
|
|
128
|
+
}, bt = {
|
|
129
129
|
de: {
|
|
130
130
|
banner: {
|
|
131
131
|
1: "EINE STUNDE",
|
|
@@ -140,7 +140,7 @@ const me = typeof import.meta < "u" && "/" || "/", F = {
|
|
|
140
140
|
10: "TEN HOURS"
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
}, le = 3633, de = 1920, Me = 0.5, Kn = Math.round(le * Me), Fn = Math.round(de * Me),
|
|
143
|
+
}, le = 3633, de = 1920, Me = 0.5, Kn = Math.round(le * Me), Fn = Math.round(de * Me), wt = 320, yt = 335, K = {
|
|
144
144
|
// Number badge positions (4 corners) - centered at ornament positions
|
|
145
145
|
badges: {
|
|
146
146
|
topLeft: { x: 286, y: 235 },
|
|
@@ -160,7 +160,7 @@ const me = typeof import.meta < "u" && "/" || "/", F = {
|
|
|
160
160
|
color: "#2a3a2a"
|
|
161
161
|
}
|
|
162
162
|
}, Le = /* @__PURE__ */ new Map(), se = /* @__PURE__ */ new Map(), Ke = /* @__PURE__ */ new Map(), Fe = /* @__PURE__ */ new Map(), qe = /* @__PURE__ */ new Map();
|
|
163
|
-
function
|
|
163
|
+
function vt(e, t, n, a, r, c, i) {
|
|
164
164
|
e.save(), e.font = `900 ${c}px "Times New Roman", Georgia, serif`, e.fillStyle = i, e.textAlign = "center", e.textBaseline = "middle";
|
|
165
165
|
const o = e.measureText(t).width / r, l = -Math.PI / 2 - o / 2, m = t.split(""), p = [];
|
|
166
166
|
for (const g of m)
|
|
@@ -208,15 +208,15 @@ function Zt(e, t) {
|
|
|
208
208
|
r.width = n, r.height = a;
|
|
209
209
|
const c = r.getContext("2d");
|
|
210
210
|
if (!c) throw new Error("Failed to get canvas context");
|
|
211
|
-
const i =
|
|
211
|
+
const i = wt * e, s = yt * e, o = K.badges, l = (m, p) => {
|
|
212
212
|
const h = p / 2, g = m.x * e - h, w = m.y * e - h;
|
|
213
213
|
c.drawImage(t, g, w, p, p);
|
|
214
214
|
};
|
|
215
215
|
return l(o.topLeft, i), l(o.topRight, i), l(o.bottomLeft, s), l(o.bottomRight, s), r.toDataURL("image/png");
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
const r =
|
|
219
|
-
|
|
217
|
+
function xt(e, t, n, a = 1) {
|
|
218
|
+
const r = bt[n].banner[t];
|
|
219
|
+
vt(
|
|
220
220
|
e,
|
|
221
221
|
r,
|
|
222
222
|
K.banner.centerX * a,
|
|
@@ -226,22 +226,22 @@ function vt(e, t, n, a = 1) {
|
|
|
226
226
|
K.banner.color
|
|
227
227
|
);
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function It(e, t, n, a, r, c, i) {
|
|
230
230
|
const s = Math.round(le * a), o = Math.round(de * a), l = document.createElement("canvas");
|
|
231
231
|
l.width = s, l.height = o;
|
|
232
232
|
const m = l.getContext("2d");
|
|
233
233
|
if (!m) throw new Error("Failed to get canvas context");
|
|
234
234
|
m.drawImage(r, 0, 0, s, o);
|
|
235
235
|
{
|
|
236
|
-
const h =
|
|
236
|
+
const h = wt * a, g = yt * a, w = K.badges, I = (d, k) => {
|
|
237
237
|
const E = k / 2, x = d.x * a - E, P = d.y * a - E;
|
|
238
238
|
m.drawImage(i, x, P, k, k);
|
|
239
239
|
};
|
|
240
240
|
I(w.topLeft, h), I(w.topRight, h), I(w.bottomLeft, g), I(w.bottomRight, g);
|
|
241
241
|
}
|
|
242
242
|
if (m.drawImage(c, 0, 0, s, o), n === "front") {
|
|
243
|
-
const h =
|
|
244
|
-
|
|
243
|
+
const h = bt[t].banner[e];
|
|
244
|
+
vt(
|
|
245
245
|
m,
|
|
246
246
|
h,
|
|
247
247
|
K.banner.centerX * a,
|
|
@@ -258,14 +258,14 @@ async function Jt(e, t, n) {
|
|
|
258
258
|
const a = `${e}-${t}-${n}`;
|
|
259
259
|
if (Le.has(a))
|
|
260
260
|
return Le.get(a);
|
|
261
|
-
const r = G.background || await C(F.background), c = n === "front" ? G.frontFrame || await C(F.frontFrame) : G.backFrame || await C(F.backFrame), i = G.badges[e] || await C(he[e]), s =
|
|
261
|
+
const r = G.background || await C(F.background), c = n === "front" ? G.frontFrame || await C(F.frontFrame) : G.backFrame || await C(F.backFrame), i = G.badges[e] || await C(he[e]), s = It(e, t, n, Me, r, c, i);
|
|
262
262
|
return Le.set(a, s), s;
|
|
263
263
|
}
|
|
264
264
|
async function st(e, t, n) {
|
|
265
265
|
const a = `${e}-${t}-${n}`;
|
|
266
266
|
if (se.has(a))
|
|
267
267
|
return se.get(a);
|
|
268
|
-
const r = G.background || await C(F.background), c = n === "front" ? G.frontFrame || await C(F.frontFrame) : G.backFrame || await C(F.backFrame), i = G.badges[e] || await C(he[e]), s =
|
|
268
|
+
const r = G.background || await C(F.background), c = n === "front" ? G.frontFrame || await C(F.frontFrame) : G.backFrame || await C(F.backFrame), i = G.badges[e] || await C(he[e]), s = It(e, t, n, 1, r, c, i);
|
|
269
269
|
if (se.size > 4) {
|
|
270
270
|
const o = se.keys().next().value;
|
|
271
271
|
o && se.delete(o);
|
|
@@ -315,7 +315,7 @@ async function Jn() {
|
|
|
315
315
|
}
|
|
316
316
|
const Re = /* @__PURE__ */ new Map(), ce = /* @__PURE__ */ new Map();
|
|
317
317
|
function en() {
|
|
318
|
-
ce.clear(), Re.clear();
|
|
318
|
+
ce.clear(), Re.clear(), ht();
|
|
319
319
|
}
|
|
320
320
|
async function C(e) {
|
|
321
321
|
return Re.has(e) ? Re.get(e) : new Promise((t, n) => {
|
|
@@ -329,7 +329,7 @@ function pe(e, t, n, a) {
|
|
|
329
329
|
e.drawImage(t, 0, 0, n, a);
|
|
330
330
|
}
|
|
331
331
|
const tn = 29, nn = 5;
|
|
332
|
-
async function
|
|
332
|
+
async function kt(e, t, n, a) {
|
|
333
333
|
if (Math.abs(t - tn) <= nn)
|
|
334
334
|
return C(e);
|
|
335
335
|
const r = `${e}:${t}:${n}x${a}`;
|
|
@@ -358,7 +358,7 @@ function rn(e, t, n, a, r, c, i = 1, s = 0, o = 0) {
|
|
|
358
358
|
const I = Math.max(0, (g - p) / 2), d = Math.max(0, (w - h) / 2), k = n - g / 2 + s * I, E = a - w / 2 + o * d;
|
|
359
359
|
e.drawImage(t, k, E, g, w), e.restore();
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function Tt(e, t, n, a = "#2a3a2a") {
|
|
362
362
|
e.save(), e.font = `${n.fontSize}px "Times New Roman", serif`, e.textAlign = n.align || "center", e.textBaseline = "middle", e.fillStyle = a, n.maxWidth ? e.fillText(t, n.x, n.y, n.maxWidth) : e.fillText(t, n.x, n.y), e.restore();
|
|
363
363
|
}
|
|
364
364
|
function on(e, t, n, a = "#2a3a2a") {
|
|
@@ -395,7 +395,7 @@ async function ln(e, t, n, a, r, c, i, s, o, l = 1, m = 0, p = 0, h = 0, g = 1,
|
|
|
395
395
|
const k = d.getContext("2d");
|
|
396
396
|
if (!k) return;
|
|
397
397
|
k.clearRect(0, 0, s, o);
|
|
398
|
-
const E = await
|
|
398
|
+
const E = await kt(t, h, s, o);
|
|
399
399
|
pe(k, E, s, o);
|
|
400
400
|
const x = await C(n);
|
|
401
401
|
if (pe(k, x, s, o), r)
|
|
@@ -427,7 +427,7 @@ async function ln(e, t, n, a, r, c, i, s, o, l = 1, m = 0, p = 0, h = 0, g = 1,
|
|
|
427
427
|
const P = await C(a);
|
|
428
428
|
pe(k, P, s, o);
|
|
429
429
|
const L = s / 3633;
|
|
430
|
-
|
|
430
|
+
xt(k, g, w, L), c && Tt(k, c, i.namePlate), e.width = s, e.height = o, I.drawImage(d, 0, 0);
|
|
431
431
|
}
|
|
432
432
|
async function dn(e, t, n, a, r, c, i, s, o, l, m, p = 0, h = 1, g = "de") {
|
|
433
433
|
const w = e.getContext("2d");
|
|
@@ -437,14 +437,14 @@ async function dn(e, t, n, a, r, c, i, s, o, l, m, p = 0, h = 1, g = "de") {
|
|
|
437
437
|
const d = I.getContext("2d");
|
|
438
438
|
if (!d) return;
|
|
439
439
|
d.clearRect(0, 0, l, m);
|
|
440
|
-
const k = await
|
|
440
|
+
const k = await kt(t, p, l, m);
|
|
441
441
|
pe(d, k, l, m);
|
|
442
442
|
const E = await C(n);
|
|
443
443
|
pe(d, E, l, m);
|
|
444
444
|
const x = await C(a);
|
|
445
445
|
pe(d, x, l, m);
|
|
446
446
|
const P = l / 3633;
|
|
447
|
-
if (
|
|
447
|
+
if (xt(d, h, g, P), o.contactInfo && (r || c || i) && sn(d, r, c, i, o.contactInfo), o.description && s && on(d, s, o.description), r && Tt(d, r, o.namePlate), o.signature) {
|
|
448
448
|
const L = g === "de" ? "Unterschrift" : "Signature";
|
|
449
449
|
cn(d, o.signature, L);
|
|
450
450
|
}
|
|
@@ -454,7 +454,7 @@ const Ne = "money-generator-portrait", Be = "money-generator-bg-removed";
|
|
|
454
454
|
async function un(e) {
|
|
455
455
|
try {
|
|
456
456
|
if (localStorage.removeItem(Ne), !e) return;
|
|
457
|
-
const t = await
|
|
457
|
+
const t = await pt(e);
|
|
458
458
|
try {
|
|
459
459
|
localStorage.setItem(Ne, t);
|
|
460
460
|
} catch (n) {
|
|
@@ -467,7 +467,7 @@ async function un(e) {
|
|
|
467
467
|
async function gn(e) {
|
|
468
468
|
try {
|
|
469
469
|
if (localStorage.removeItem(Be), !e) return;
|
|
470
|
-
const t = await
|
|
470
|
+
const t = await pt(e);
|
|
471
471
|
try {
|
|
472
472
|
localStorage.setItem(Be, t);
|
|
473
473
|
} catch (n) {
|
|
@@ -533,8 +533,8 @@ const Ce = fn(), lt = {
|
|
|
533
533
|
isExporting: !1,
|
|
534
534
|
appLanguage: Ce
|
|
535
535
|
// UI language - follows browser
|
|
536
|
-
}, y =
|
|
537
|
-
|
|
536
|
+
}, y = Wt()(
|
|
537
|
+
zt(
|
|
538
538
|
(e) => ({
|
|
539
539
|
...lt,
|
|
540
540
|
setPersonalInfo: (t) => e((n) => ({
|
|
@@ -819,7 +819,7 @@ const bn = {
|
|
|
819
819
|
function ue(e) {
|
|
820
820
|
return yn[e];
|
|
821
821
|
}
|
|
822
|
-
function
|
|
822
|
+
function Et(e, t, n) {
|
|
823
823
|
if (n && n.trim())
|
|
824
824
|
return n;
|
|
825
825
|
const a = ue(e), r = a.bill.bannerText[t] || a.bill.bannerText[1];
|
|
@@ -913,7 +913,7 @@ function Qn({ focusField: e, onFocused: t, onFormFocusChange: n } = {}) {
|
|
|
913
913
|
] })
|
|
914
914
|
] });
|
|
915
915
|
}
|
|
916
|
-
const Xe = {}, In = "https://api.stability.ai/v1/generation", kn = "https://api.stability.ai/v2beta/stable-image/edit/remove-background",
|
|
916
|
+
const Xe = {}, In = "https://api.stability.ai/v1/generation", kn = "https://api.stability.ai/v2beta/stable-image/edit/remove-background", Pt = "stability_api_key";
|
|
917
917
|
let be = null;
|
|
918
918
|
function ea(e) {
|
|
919
919
|
be = e;
|
|
@@ -965,7 +965,7 @@ function Pn(e) {
|
|
|
965
965
|
}, a.onerror = () => n(new Error("Failed to load image")), a.src = e;
|
|
966
966
|
});
|
|
967
967
|
}
|
|
968
|
-
function
|
|
968
|
+
function St(e) {
|
|
969
969
|
var i;
|
|
970
970
|
const t = e.split(","), n = ((i = t[0].match(/:(.*?);/)) == null ? void 0 : i[1]) || "image/png", a = atob(t[1]), r = a.length, c = new Uint8Array(r);
|
|
971
971
|
for (let s = 0; s < r; s++)
|
|
@@ -975,10 +975,10 @@ function Pt(e) {
|
|
|
975
975
|
function Qe() {
|
|
976
976
|
var t;
|
|
977
977
|
const e = typeof import.meta < "u" && (Xe == null ? void 0 : Xe.VITE_STABILITY_API_KEY) || typeof process < "u" && ((t = process.env) == null ? void 0 : t.NEXT_PUBLIC_STABILITY_API_KEY);
|
|
978
|
-
return e && e !== "your-api-key-here" ? e : typeof localStorage < "u" ? localStorage.getItem(
|
|
978
|
+
return e && e !== "your-api-key-here" ? e : typeof localStorage < "u" ? localStorage.getItem(Pt) : null;
|
|
979
979
|
}
|
|
980
980
|
function Sn(e) {
|
|
981
|
-
localStorage.setItem(
|
|
981
|
+
localStorage.setItem(Pt, e);
|
|
982
982
|
}
|
|
983
983
|
function je() {
|
|
984
984
|
return be ? !0 : Qe() !== null;
|
|
@@ -987,7 +987,7 @@ async function aa(e) {
|
|
|
987
987
|
const t = Qe();
|
|
988
988
|
if (!t)
|
|
989
989
|
throw new Error("No Stability AI API key configured");
|
|
990
|
-
const { imageDataUrl: n, style: a, strength: r = 0.35 } = e, c = await Pn(n), i =
|
|
990
|
+
const { imageDataUrl: n, style: a, strength: r = 0.35 } = e, c = await Pn(n), i = St(c), s = new FormData();
|
|
991
991
|
s.append("init_image", i, "portrait.png"), s.append("init_image_mode", "IMAGE_STRENGTH"), s.append("image_strength", String(1 - r)), s.append("text_prompts[0][text]", Tn[a]), s.append("text_prompts[0][weight]", "1"), s.append("cfg_scale", "7"), s.append("samples", "1"), s.append("steps", "30");
|
|
992
992
|
const l = await fetch(`${In}/stable-diffusion-xl-1024-v1-0/image-to-image`, {
|
|
993
993
|
method: "POST",
|
|
@@ -1024,7 +1024,7 @@ async function Ln(e) {
|
|
|
1024
1024
|
const t = Qe();
|
|
1025
1025
|
if (!t)
|
|
1026
1026
|
throw new Error("No Stability AI API key configured");
|
|
1027
|
-
const n =
|
|
1027
|
+
const n = St(e), a = new FormData();
|
|
1028
1028
|
a.append("image", n, "image.png"), a.append("output_format", "png");
|
|
1029
1029
|
const r = await fetch(kn, {
|
|
1030
1030
|
method: "POST",
|
|
@@ -1257,7 +1257,7 @@ function ra() {
|
|
|
1257
1257
|
T.onload = async (Y) => {
|
|
1258
1258
|
var X;
|
|
1259
1259
|
const M = (X = Y.target) == null ? void 0 : X.result, Z = await Xt(M);
|
|
1260
|
-
|
|
1260
|
+
ht(), c(Z), n(Z), a(1), r(0, 0), i(!1, null), s(0), o(0), l(0);
|
|
1261
1261
|
}, T.readAsDataURL(f);
|
|
1262
1262
|
},
|
|
1263
1263
|
[n, c, a, r, i, s, o, l]
|
|
@@ -1573,7 +1573,7 @@ function oa() {
|
|
|
1573
1573
|
!1
|
|
1574
1574
|
] });
|
|
1575
1575
|
}
|
|
1576
|
-
function
|
|
1576
|
+
function Lt(e, t) {
|
|
1577
1577
|
return {
|
|
1578
1578
|
front: "",
|
|
1579
1579
|
// Will be set dynamically by composeTemplate
|
|
@@ -1642,12 +1642,12 @@ const et = {
|
|
|
1642
1642
|
}
|
|
1643
1643
|
}
|
|
1644
1644
|
}, xe = et, Ie = et;
|
|
1645
|
-
function
|
|
1645
|
+
function Rt(e) {
|
|
1646
1646
|
return et;
|
|
1647
1647
|
}
|
|
1648
1648
|
const Ze = 0.75;
|
|
1649
1649
|
function Bn(e) {
|
|
1650
|
-
const t =
|
|
1650
|
+
const t = Rt(), n = Ze, a = (r) => ({
|
|
1651
1651
|
portrait: {
|
|
1652
1652
|
x: r.portrait.x * n,
|
|
1653
1653
|
y: r.portrait.y * n,
|
|
@@ -1692,7 +1692,7 @@ function Bn(e) {
|
|
|
1692
1692
|
};
|
|
1693
1693
|
}
|
|
1694
1694
|
function Cn(e, t) {
|
|
1695
|
-
const n =
|
|
1695
|
+
const n = Lt();
|
|
1696
1696
|
return {
|
|
1697
1697
|
...n,
|
|
1698
1698
|
width: Math.round(n.width * Ze),
|
|
@@ -1707,7 +1707,7 @@ function An(e, t) {
|
|
|
1707
1707
|
}, [e, t]), n;
|
|
1708
1708
|
}
|
|
1709
1709
|
function ia({ onPortraitClick: e, onFileDrop: t } = {}) {
|
|
1710
|
-
const n = y((b) => b.appLanguage), a = y((b) => b.voucherConfig.language), r = y((b) => b.voucherConfig.hours), c = y((b) => b.voucherConfig.description), i = y((b) => b.voucherConfig.templateHue), s = y((b) => b.personalInfo), o = y((b) => b.portrait), l = y((b) => b.currentSide), m = y((b) => b.flipSide), p = y((b) => b.setPortraitPan), h = An(i, 150), g = ue(n), w = W(null), I = W(null), d = W(null), [k, E] = H(!1), [x, P] = H(!1), [L, S] = H(!1), [D, A] = H(!1), R = W(null), N = W(null), $ = W(!1), ee = W(0), U = Cn(), _ = Bn(), te = o.useEnhanced && o.enhanced ? o.enhanced : o.original, ie =
|
|
1710
|
+
const n = y((b) => b.appLanguage), a = y((b) => b.voucherConfig.language), r = y((b) => b.voucherConfig.hours), c = y((b) => b.voucherConfig.description), i = y((b) => b.voucherConfig.templateHue), s = y((b) => b.personalInfo), o = y((b) => b.portrait), l = y((b) => b.currentSide), m = y((b) => b.flipSide), p = y((b) => b.setPortraitPan), h = An(i, 150), g = ue(n), w = W(null), I = W(null), d = W(null), [k, E] = H(!1), [x, P] = H(!1), [L, S] = H(!1), [D, A] = H(!1), R = W(null), N = W(null), $ = W(!1), ee = W(0), U = Cn(), _ = Bn(), te = o.useEnhanced && o.enhanced ? o.enhanced : o.original, ie = Et(a, r, c), [ne, we] = H(""), [q, ae] = H(""), [J, ye] = H(""), [re, ke] = H(""), [oe, He] = H(""), [ve, Ue] = H(""), [Te, Ee] = H(!0);
|
|
1711
1711
|
j(() => {
|
|
1712
1712
|
let b = !0;
|
|
1713
1713
|
Ee(!0);
|
|
@@ -1765,7 +1765,7 @@ function ia({ onPortraitClick: e, onFileDrop: t } = {}) {
|
|
|
1765
1765
|
}, [l]);
|
|
1766
1766
|
const T = O((b, B) => {
|
|
1767
1767
|
if (!d.current || l !== "front") return !1;
|
|
1768
|
-
const z = d.current.getBoundingClientRect(), V = z.width / U.width, Oe = z.height / U.height, Pe = (b - z.left) / V, Ye = (B - z.top) / Oe, { x: We, y: ze, radiusX: _e, radiusY:
|
|
1768
|
+
const z = d.current.getBoundingClientRect(), V = z.width / U.width, Oe = z.height / U.height, Pe = (b - z.left) / V, Ye = (B - z.top) / Oe, { x: We, y: ze, radiusX: _e, radiusY: Yt } = _.front.portrait, at = (Pe - We) / _e, rt = (Ye - ze) / Yt;
|
|
1769
1769
|
return at * at + rt * rt <= 1;
|
|
1770
1770
|
}, [l, U.width, U.height, _.front.portrait]), Y = 5, M = O((b, B) => {
|
|
1771
1771
|
o.original && (P(!0), R.current = {
|
|
@@ -1785,29 +1785,29 @@ function ia({ onPortraitClick: e, onFileDrop: t } = {}) {
|
|
|
1785
1785
|
P(!1), R.current = null, N.current = null;
|
|
1786
1786
|
}, []), tt = O(() => {
|
|
1787
1787
|
e && e();
|
|
1788
|
-
}, [e]),
|
|
1788
|
+
}, [e]), Nt = (b) => {
|
|
1789
1789
|
T(b.clientX, b.clientY) && (b.preventDefault(), N.current = { x: b.clientX, y: b.clientY }, $.current = !1);
|
|
1790
|
-
},
|
|
1790
|
+
}, Bt = (b) => {
|
|
1791
1791
|
if (S(T(b.clientX, b.clientY)), N.current && o.original) {
|
|
1792
1792
|
const B = b.clientX - N.current.x, z = b.clientY - N.current.y;
|
|
1793
1793
|
Math.sqrt(B * B + z * z) > Y && !x && ($.current = !0, M(N.current.x, N.current.y));
|
|
1794
1794
|
}
|
|
1795
1795
|
x && Z(b.clientX, b.clientY);
|
|
1796
|
-
},
|
|
1796
|
+
}, Ct = (b) => {
|
|
1797
1797
|
N.current && !$.current && T(b.clientX, b.clientY) && tt(), X();
|
|
1798
|
-
},
|
|
1798
|
+
}, At = () => {
|
|
1799
1799
|
X(), S(!1);
|
|
1800
|
-
},
|
|
1800
|
+
}, Mt = (b) => {
|
|
1801
1801
|
if (b.touches.length === 1) {
|
|
1802
1802
|
const B = b.touches[0];
|
|
1803
1803
|
T(B.clientX, B.clientY) && (N.current = { x: B.clientX, y: B.clientY }, $.current = !1);
|
|
1804
1804
|
}
|
|
1805
|
-
},
|
|
1805
|
+
}, Dt = (b) => {
|
|
1806
1806
|
if (b.touches.length === 1 && N.current && o.original) {
|
|
1807
1807
|
const B = b.touches[0], z = B.clientX - N.current.x, V = B.clientY - N.current.y;
|
|
1808
1808
|
Math.sqrt(z * z + V * V) > Y && !x && ($.current = !0, M(N.current.x, N.current.y)), x && Z(B.clientX, B.clientY);
|
|
1809
1809
|
}
|
|
1810
|
-
},
|
|
1810
|
+
}, Ht = () => {
|
|
1811
1811
|
N.current && !$.current && T(N.current.x, N.current.y) && tt(), X();
|
|
1812
1812
|
}, nt = W(!1);
|
|
1813
1813
|
j(() => {
|
|
@@ -1822,7 +1822,7 @@ function ia({ onPortraitClick: e, onFileDrop: t } = {}) {
|
|
|
1822
1822
|
b.removeEventListener("touchmove", B);
|
|
1823
1823
|
};
|
|
1824
1824
|
}, []);
|
|
1825
|
-
const
|
|
1825
|
+
const Ut = l === "front" && o.original, Ot = U.width / U.height;
|
|
1826
1826
|
return /* @__PURE__ */ v("div", { className: "space-y-2", children: [
|
|
1827
1827
|
/* @__PURE__ */ v("div", { className: "flex justify-between items-center mb-6", children: [
|
|
1828
1828
|
/* @__PURE__ */ v("div", { className: "join border border-base-300 rounded-lg", children: [
|
|
@@ -1870,26 +1870,26 @@ function ia({ onPortraitClick: e, onFileDrop: t } = {}) {
|
|
|
1870
1870
|
"div",
|
|
1871
1871
|
{
|
|
1872
1872
|
className: "relative w-full overflow-visible",
|
|
1873
|
-
style: { aspectRatio:
|
|
1873
|
+
style: { aspectRatio: Ot, perspective: "1500px" },
|
|
1874
1874
|
children: [
|
|
1875
1875
|
Te && /* @__PURE__ */ u("div", { className: "absolute inset-0 flex items-center justify-center bg-base-300 rounded-lg z-10", children: /* @__PURE__ */ u("span", { className: "loading loading-spinner loading-lg text-primary" }) }),
|
|
1876
1876
|
/* @__PURE__ */ v(
|
|
1877
1877
|
"div",
|
|
1878
1878
|
{
|
|
1879
1879
|
ref: d,
|
|
1880
|
-
className: `relative w-full h-full shadow-lg ${L &&
|
|
1880
|
+
className: `relative w-full h-full shadow-lg ${L && Ut ? x ? "cursor-grabbing" : "cursor-grab" : ""} ${Te ? "opacity-0" : "opacity-100"} transition-opacity duration-300`,
|
|
1881
1881
|
style: {
|
|
1882
1882
|
transformStyle: "preserve-3d",
|
|
1883
1883
|
transition: "transform 0.6s ease-in-out, opacity 0.3s ease-in-out",
|
|
1884
1884
|
transform: k ? "rotateY(180deg)" : "rotateY(0deg)"
|
|
1885
1885
|
},
|
|
1886
|
-
onMouseDown:
|
|
1887
|
-
onMouseMove:
|
|
1888
|
-
onMouseUp:
|
|
1889
|
-
onMouseLeave:
|
|
1890
|
-
onTouchStart:
|
|
1891
|
-
onTouchMove:
|
|
1892
|
-
onTouchEnd:
|
|
1886
|
+
onMouseDown: Nt,
|
|
1887
|
+
onMouseMove: Bt,
|
|
1888
|
+
onMouseUp: Ct,
|
|
1889
|
+
onMouseLeave: At,
|
|
1890
|
+
onTouchStart: Mt,
|
|
1891
|
+
onTouchMove: Dt,
|
|
1892
|
+
onTouchEnd: Ht,
|
|
1893
1893
|
onDragOver: (b) => {
|
|
1894
1894
|
b.preventDefault(), l === "front" && A(!0);
|
|
1895
1895
|
},
|
|
@@ -2510,7 +2510,7 @@ async function Hn(e) {
|
|
|
2510
2510
|
L(new Error("Invalid response from worker"));
|
|
2511
2511
|
return;
|
|
2512
2512
|
}
|
|
2513
|
-
const te = gt($, "image/jpeg"), ie = gt(ee, "image/jpeg"), ne = 138.6, we = 72.9, q = ne, ae = we, J = new
|
|
2513
|
+
const te = gt($, "image/jpeg"), ie = gt(ee, "image/jpeg"), ne = 138.6, we = 72.9, q = ne, ae = we, J = new _t({
|
|
2514
2514
|
orientation: q > ae ? "landscape" : "portrait",
|
|
2515
2515
|
unit: "mm",
|
|
2516
2516
|
format: [q, ae]
|
|
@@ -2567,7 +2567,7 @@ async function On(e) {
|
|
|
2567
2567
|
Un(t, e.filename);
|
|
2568
2568
|
}
|
|
2569
2569
|
function ca() {
|
|
2570
|
-
const e = y((d) => d.appLanguage), t = y((d) => d.voucherConfig.language), n = y((d) => d.voucherConfig.hours), a = y((d) => d.voucherConfig.description), r = y((d) => d.voucherConfig.templateHue), c = y((d) => d.personalInfo), i = y((d) => d.portrait), s = y((d) => d.isExporting), o = y((d) => d.setIsExporting), l = ue(e), m =
|
|
2570
|
+
const e = y((d) => d.appLanguage), t = y((d) => d.voucherConfig.language), n = y((d) => d.voucherConfig.hours), a = y((d) => d.voucherConfig.description), r = y((d) => d.voucherConfig.templateHue), c = y((d) => d.personalInfo), i = y((d) => d.portrait), s = y((d) => d.isExporting), o = y((d) => d.setIsExporting), l = ue(e), m = Lt(), p = Rt(), h = i.useEnhanced && i.enhanced ? i.enhanced : i.original, g = Et(t, n, a), w = c.name.trim().length > 0 && c.email.trim().length > 0 && c.phone.trim().length > 0 && i.original !== null;
|
|
2571
2571
|
return /* @__PURE__ */ v(
|
|
2572
2572
|
"button",
|
|
2573
2573
|
{
|
|
@@ -2851,16 +2851,16 @@ export {
|
|
|
2851
2851
|
on as drawMultilineText,
|
|
2852
2852
|
rn as drawOvalPortrait,
|
|
2853
2853
|
pe as drawTemplate,
|
|
2854
|
-
|
|
2854
|
+
Tt as drawText,
|
|
2855
2855
|
aa as enhancePortrait,
|
|
2856
2856
|
On as exportBillAsPDF,
|
|
2857
|
-
|
|
2857
|
+
Et as formatDescription,
|
|
2858
2858
|
Hn as generateBillPDF,
|
|
2859
2859
|
Qe as getApiKey,
|
|
2860
2860
|
da as getDefaultTemplateId,
|
|
2861
|
-
|
|
2861
|
+
Rt as getLayout,
|
|
2862
2862
|
ta as getRemoveBackgroundEndpoint,
|
|
2863
|
-
|
|
2863
|
+
Lt as getTemplate,
|
|
2864
2864
|
ha as getTemplateById,
|
|
2865
2865
|
Zn as getTemplateDimensions,
|
|
2866
2866
|
ct as getTemplateLayers,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antontranelis/money-printer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.86",
|
|
4
4
|
"description": "Create personalized time vouchers that look like real currency. React components for voucher generation with PDF export.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|