import{i as e,t}from"./react.C6f1lhbS.js";import{n,r,t as i}from"./jsx-runtime.DAnAtnt1.js";import{t as a}from"./esm.BUTgtTat.js";var o=r(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),s=e(t(),1),c=i(),l=({siteUrl:e})=>{let[t,r]=(0,s.useState)(``),[i,l]=(0,s.useState)(`B`),[u,d]=(0,s.useState)(`G`),f=(0,s.useRef)(null),p=e?.endsWith(`/`)?e.slice(0,-1):e||``;(0,s.useEffect)(()=>{fetch(`/api/config`).then(e=>e.json()).then(e=>{e.BRIDE_NICKNAME&&l(e.BRIDE_NICKNAME.charAt(0).toUpperCase()),e.GROOM_NICKNAME&&d(e.GROOM_NICKNAME.charAt(0).toUpperCase())}).catch(()=>{})},[]);let m=()=>t?`${p}/?to=${encodeURIComponent(t.trim())}`:p,h=(0,s.useMemo)(()=>{try{let e=`
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
          <defs>
            <linearGradient id="goldGradient" x1="0%" y1="0%" x2="100%" y2="100%">
              <stop offset="0%" style="stop-color:#F59E0B;stop-opacity:1" />
              <stop offset="100%" style="stop-color:#B45309;stop-opacity:1" />
            </linearGradient>
          </defs>
          <circle cx="50" cy="50" r="48" fill="white" />
          <circle cx="50" cy="50" r="46" fill="none" stroke="url(#goldGradient)" stroke-width="2" />
          <circle cx="50" cy="50" r="42" fill="none" stroke="#f1f5f9" stroke-width="1" />
          <g font-family="'Times New Roman', Times, serif" font-weight="bold" font-size="40" fill="#334155" text-anchor="middle">
             <text x="26" y="64">${i}</text>
             <text x="74" y="64">${u}</text>
          </g>
          <path d="M50 38 C 46 32, 36 33, 36 42 C 36 52, 50 64, 50 64 C 50 64, 64 52, 64 42 C 64 33, 54 32, 50 38 Z" fill="#e11d48" stroke="white" stroke-width="1.5" />
        </svg>
      `.trim();return`data:image/svg+xml;base64,${btoa(e)}`}catch{return``}},[i,u]);return(0,c.jsxs)(`div`,{className:`animate-reveal grid items-center gap-10 md:grid-cols-2`,children:[(0,c.jsxs)(`div`,{className:`space-y-6`,children:[(0,c.jsxs)(`div`,{className:`space-y-2`,children:[(0,c.jsx)(`label`,{className:`text-xs font-bold tracking-widest text-slate-400 uppercase`,children:`Nama Tamu`}),(0,c.jsx)(`input`,{type:`text`,value:t,onChange:e=>r(e.target.value),placeholder:`Contoh: Ahmad Syarief Ramadhan & Partner`,className:`w-full rounded-xl border border-slate-200 bg-slate-50 px-4 py-4 text-lg transition-all focus:ring-2 focus:ring-blue-500 focus:outline-none dark:border-slate-700 dark:bg-slate-900 dark:text-white`}),(0,c.jsx)(`p`,{className:`text-xs text-slate-400 italic`,children:`*Nama akan otomatis muncul di sampul undangan & form RSVP.`})]}),(0,c.jsx)(`div`,{className:`rounded-xl border border-slate-200 bg-slate-50 p-4 font-mono text-xs break-all text-slate-500 dark:border-slate-700 dark:bg-slate-900/50`,children:m()}),(0,c.jsxs)(`div`,{className:`flex gap-4`,children:[(0,c.jsxs)(`button`,{onClick:()=>{navigator.clipboard.writeText(m()),alert(`Link berhasil disalin!`)},className:`flex flex-1 items-center justify-center gap-2 rounded-xl border border-slate-200 py-3 text-xs font-bold uppercase transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800`,children:[(0,c.jsx)(o,{className:`h-4 w-4`}),` Copy Link`]}),(0,c.jsxs)(`button`,{onClick:()=>{let e=f.current;if(e){let n=e.toDataURL(`image/png`),r=document.createElement(`a`);r.href=n,r.download=`QR-${t||`Wedding`}.png`,document.body.appendChild(r),r.click(),document.body.removeChild(r)}},disabled:!t,className:`flex flex-1 items-center justify-center gap-2 rounded-xl bg-blue-600 py-3 text-xs font-bold text-white uppercase shadow-lg transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,c.jsx)(n,{className:`h-4 w-4`}),` Download QR`]})]})]}),(0,c.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-3xl border-2 border-dashed border-slate-200 bg-white p-8 dark:border-white/10 dark:bg-white/5`,children:[(0,c.jsx)(`div`,{className:`rounded-2xl border border-slate-100 bg-white p-6 shadow-xl`,children:(0,c.jsx)(a,{ref:f,value:m(),size:280,level:`H`,includeMargin:!0,imageSettings:h?{src:h,height:60,width:60,excavate:!0}:void 0})}),(0,c.jsxs)(`div`,{className:`mt-8 space-y-1 text-center`,children:[(0,c.jsx)(`p`,{className:`text-sm font-bold tracking-widest text-slate-400 uppercase`,children:`Preview Result`}),t&&(0,c.jsxs)(`p`,{className:`font-serif text-lg text-slate-800 italic dark:text-white`,children:[`"`,t,`"`]})]})]})]})};export{l as default};