var __gh = require("react").createElement, __gf = require("react").Fragment; var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var stdin_exports={};__export(stdin_exports,{default:()=>stdin_default,featureConfig:()=>featureConfig});module.exports=__toCommonJS(stdin_exports);var dataSources=[{key:"contratos",table:"pms__contratos",access:["public:read"],sensitive:["codigo","alojamiento_id","inquilino_id","tipo","fecha_inicio","fecha_fin","mensualidad","fianza","fianza_estado","dia_cobro","suministros_cubiertos","renovacion","estado","notas","firma_estado","firma_token","firmado_por","firmado_email","firmado_at","pdf_url","contrato_html","firma_cliente","firma_fecha","firma_ip","firma_completada","pdf_contrato","ocupantes","num_trabajadores","firma_token_arrendatario","firma_token_arrendador","inmueble_id","firma_arrendador","firma_arrendador_fecha","firma_arrendador_ip","firma_arrendador_nombre","alojamiento_id__display","inquilino_id__display","inmueble_id__display","estado__display","firma_estado__display","fianza_estado__display","renovacion__display","tipo__display"]},{key:"inquilinos",table:"pms__inquilinos",access:["public:read"],sensitive:["nombre","email","telefono","dni","empresa","idioma","estado","notas","clave_portal","empresa_nif","empresa_direccion","cargo","estado__display","idioma__display"]}];var featureConfig={dataSources,seedData:[],meta:{name:"Firma de contrato (p\xFAblico)",version:"1.0.0"}};var import_react=require("react"),import_framer_motion=require("framer-motion"),import_lucide_react=require("lucide-react"),COMPANY_ID=811,API_BASE=typeof window<"u"&&window.location.hostname==="localhost"?"http://localhost:3000":"",ACCENT="#3F5244",EASE=[.4,0,.2,1];function readUrlParams(){if(typeof window>"u")return{code:"",dni:"",previewToken:"",role:"arrendatario"};let segments=window.location.pathname.split("/").filter(Boolean),search=new URLSearchParams(window.location.search),code=search.get("c")||search.get("code")||"";code||(segments.length===2&&segments[0].toLowerCase()==="sign"?code=segments[1]:segments.length===1&&segments[0].toLowerCase()!=="sign"&&(code=segments[0]));let r=(search.get("r")||search.get("rol")||search.get("role")||"").trim().toLowerCase(),role=r==="arrendador"||r==="propietario"?"arrendador":"arrendatario";return{code:code.trim(),dni:(search.get("dni")||"").trim(),previewToken:(search.get("preview")||"").trim(),role,token:(search.get("t")||search.get("token")||"").trim()}}function formatLongDate(d){if(!d)return"";try{return new Date(d).toLocaleDateString("es-ES",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}}function downloadPdfFromBase64(base64,filename){let byteChars=atob(base64),byteNumbers=new Array(byteChars.length);for(let i=0;iURL.revokeObjectURL(url),1e3)}async function callPublicAutomation(name,body){let res=await fetch(`${API_BASE}/api/public/${COMPANY_ID}/automation/${name}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)}),json=await res.json().catch(()=>({}));if(!res.ok){let err=new Error(json&&(json.error||json.message)||"Request failed");throw err.status=res.status,err.body=json,err}if(json&&json.success===!1){let err=new Error(json.error||json.message||"Automation failed");throw err.status=res.status,err.body=json,err}return json&&typeof json=="object"&&"result"in json?json.result:json}function FirmaContratoRumar({id,gufi}){let[params]=(0,import_react.useState)(()=>readUrlParams()),role=params.role,esArrendador=role==="arrendador",token=params.token,[step,setStep]=(0,import_react.useState)("verify"),[data,setData]=(0,import_react.useState)(null),[dni,setDni]=(0,import_react.useState)(params.dni),[error,setError]=(0,import_react.useState)(null),[loadingVerify,setLoadingVerify]=(0,import_react.useState)(!1),[loadingSign,setLoadingSign]=(0,import_react.useState)(!1),[pdfBase64,setPdfBase64]=(0,import_react.useState)(null),[pdfFilename,setPdfFilename]=(0,import_react.useState)(null),[emailSent,setEmailSent]=(0,import_react.useState)(!1),[clientEmail,setClientEmail]=(0,import_react.useState)(null),[accepted,setAccepted]=(0,import_react.useState)(!1),[hasSignature,setHasSignature]=(0,import_react.useState)(!1),[completo,setCompleto]=(0,import_react.useState)(null),canvasRef=(0,import_react.useRef)(null),drawingRef=(0,import_react.useRef)(!1),lastPointRef=(0,import_react.useRef)(null),hasSignatureRef=(0,import_react.useRef)(!1),code=params.code,codeMissing=!code,previewToken=params.previewToken,previewMode=!!previewToken,initCanvas=(0,import_react.useCallback)(()=>{let canvas=canvasRef.current;if(!canvas)return;let rect=canvas.getBoundingClientRect();if(rect.width===0)return;let ratio=Math.max(window.devicePixelRatio||1,1);canvas.width=rect.width*ratio,canvas.height=rect.height*ratio;let ctx=canvas.getContext("2d");ctx&&(ctx.scale(ratio,ratio),ctx.fillStyle="#ffffff",ctx.fillRect(0,0,rect.width,rect.height),ctx.lineCap="round",ctx.lineJoin="round",ctx.strokeStyle="#111827",ctx.lineWidth=2.4,hasSignatureRef.current=!1,setHasSignature(!1))},[]);(0,import_react.useEffect)(()=>{if(step!=="sign"||previewMode)return;let raf=requestAnimationFrame(()=>initCanvas());return()=>cancelAnimationFrame(raf)},[step,previewMode,initCanvas]),(0,import_react.useEffect)(()=>{if(step!=="sign"||previewMode)return;let t,onResize=()=>{hasSignatureRef.current||(clearTimeout(t),t=setTimeout(initCanvas,150))};return window.addEventListener("resize",onResize),()=>{window.removeEventListener("resize",onResize),clearTimeout(t)}},[step,previewMode,initCanvas]);let pointerPos=e=>{let rect=canvasRef.current.getBoundingClientRect();return{x:e.clientX-rect.left,y:e.clientY-rect.top}},onPointerDown=e=>{e.preventDefault(),drawingRef.current=!0,lastPointRef.current=pointerPos(e.nativeEvent),canvasRef.current?.setPointerCapture(e.pointerId)},onPointerMove=e=>{if(!drawingRef.current)return;let canvas=canvasRef.current;if(!canvas)return;let ctx=canvas.getContext("2d");if(!ctx)return;let p=pointerPos(e.nativeEvent),last=lastPointRef.current||p;ctx.beginPath(),ctx.moveTo(last.x,last.y),ctx.lineTo(p.x,p.y),ctx.stroke(),lastPointRef.current=p,hasSignatureRef.current||(hasSignatureRef.current=!0,setHasSignature(!0),setError(null))},onPointerUp=e=>{drawingRef.current=!1,lastPointRef.current=null,canvasRef.current?.releasePointerCapture(e.pointerId)},clearSignature=()=>{initCanvas()},verifyDni=async e=>{if(e?.preventDefault(),!dni.trim()){setError("Introduce tu DNI/NIF");return}setLoadingVerify(!0),setError(null);try{let result=await callPublicAutomation("sign_verify_dni",{contract_code:code,dni:dni.trim(),role,token});if(!result||!result.ok){setError("Verificaci\xF3n fallida. Revisa tu DNI/NIF e int\xE9ntalo de nuevo.");return}if(setData(result),result.firmado){setStep("success");return}setStep("sign")}catch(err){let status=err&&err.status;setError(status===429?"Demasiados intentos. Espera unos minutos.":"Verificaci\xF3n fallida. Revisa tu DNI/NIF e int\xE9ntalo de nuevo.")}finally{setLoadingVerify(!1)}};(0,import_react.useEffect)(()=>{if(!previewMode||!code)return;let cancelled=!1;return(async()=>{setLoadingVerify(!0),setError(null);try{let result=await callPublicAutomation("sign_verify_dni",{contract_code:code,preview_token:previewToken,role,token});if(cancelled)return;if(!result||!result.ok){setError("No se pudo cargar la previsualizaci\xF3n. El enlace puede no ser v\xE1lido.");return}setData(result),setStep("sign")}catch{cancelled||setError("No se pudo cargar la previsualizaci\xF3n.")}finally{cancelled||setLoadingVerify(!1)}})(),()=>{cancelled=!0}},[previewMode,code,previewToken]);let submitSignature=async()=>{if(!canvasRef.current||!hasSignatureRef.current){setError("Dibuja tu firma antes de continuar.");return}if(!accepted){setError("Acepta las condiciones del contrato para continuar.");return}setLoadingSign(!0),setError(null);try{let signatureBase64=canvasRef.current.toDataURL("image/png"),result=await callPublicAutomation("sign_submit",{contract_code:code,dni:dni.trim(),signature_base64:signatureBase64,user_agent:navigator.userAgent,role,token});if(!result||!result.ok){setError("No se pudo registrar la firma. Int\xE9ntalo de nuevo.");return}setPdfBase64(result.pdf_base64||null),setPdfFilename(result.pdf_filename||null),setEmailSent(!!result.hasEmail),setCompleto(typeof result.completo=="boolean"?result.completo:null),setClientEmail(result.client_email||(data?.inquilino?.email??null)),setStep("success")}catch(err){setError(err&&err.message||"Error registrando la firma")}finally{setLoadingSign(!1)}};return codeMissing?__gh(ErrorScreen,{title:"Enlace inv\xE1lido",message:"Pide a Rumar Flats que te reenv\xEDe el enlace de firma."}):__gh(Layout,null,__gh(import_framer_motion.AnimatePresence,{mode:"wait",initial:!1},step==="verify"&&!previewMode&&__gh(import_framer_motion.motion.div,{key:"verify",initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.35,ease:EASE},className:"w-full"},__gh(VerifyScreen,{dni,setDni,error,setError,loading:loadingVerify,onSubmit:verifyDni,esArrendador})),step==="verify"&&previewMode&&__gh(import_framer_motion.motion.div,{key:"preview-loading",initial:{opacity:0},animate:{opacity:1},className:"w-full"},error?__gh(ErrorScreen,{title:"No se pudo previsualizar",message:error}):__gh("div",{className:"max-w-md mx-auto text-center py-24 text-zinc-500","data-gufi-src":"page.tsx:352"},__gh(import_lucide_react.Loader2,{className:"w-7 h-7 animate-spin mx-auto mb-4",style:{color:ACCENT}}),"Cargando previsualizaci\xF3n del contrato\u2026")),step==="sign"&&data&&__gh(import_framer_motion.motion.div,{key:"sign",initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},transition:{duration:.4,ease:EASE},className:"w-full"},__gh(SignScreen,{data,previewMode,esArrendador,canvasRef,onPointerDown,onPointerMove,onPointerUp,onClearSignature:clearSignature,hasSignature,accepted,setAccepted,error,loading:loadingSign,onSubmit:submitSignature})),step==="success"&&__gh(import_framer_motion.motion.div,{key:"success",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.45,ease:EASE},className:"w-full"},__gh(SuccessScreen,{data,emailSent,clientEmail,pdfBase64,pdfFilename,completo,esArrendador}))))}function VerifyScreen({dni,setDni,error,setError,loading,onSubmit,esArrendador}){return __gh("div",{className:"bg-white rounded-3xl shadow-xl border border-zinc-100 p-8 max-w-md w-full mx-auto","data-gufi-src":"page.tsx:406"},__gh(BrandMark,null),__gh("div",{className:"text-center mb-8","data-gufi-src":"page.tsx:408"},__gh("h1",{className:"text-2xl font-bold text-zinc-900 mb-2","data-gufi-src":"page.tsx:409"},"Verificaci\xF3n de identidad"),__gh("p",{className:"text-zinc-500","data-gufi-src":"page.tsx:410"},esArrendador?"Firmas como parte arrendadora. Introduce el DNI del firmante autorizado para acceder al contrato.":"Introduce tu DNI/NIF para acceder a tu contrato y firmarlo.")),__gh("form",{onSubmit,className:"space-y-4","data-gufi-src":"page.tsx:417"},__gh("div",{"data-gufi-src":"page.tsx:418"},__gh("label",{className:"block text-sm font-medium text-zinc-700 mb-2","data-gufi-src":"page.tsx:419"},"DNI / NIF"),__gh("div",{className:"relative","data-gufi-src":"page.tsx:420"},__gh(import_lucide_react.IdCard,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-zinc-400"}),__gh("input",{type:"text",value:dni,onChange:e=>{setDni(e.target.value.toUpperCase()),setError(null)},placeholder:"12345678X",className:"rm-input w-full pl-12 pr-4 py-4 rounded-xl border border-zinc-200 text-lg font-medium tracking-wide uppercase outline-none transition-all duration-200",autoFocus:!0,autoComplete:"off","data-gufi-src":"page.tsx:422"})),error&&__gh(import_framer_motion.motion.p,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},transition:{duration:.2,ease:EASE},className:"text-sm text-rose-600 mt-2 flex items-center gap-1"},__gh(import_lucide_react.AlertCircle,{className:"w-4 h-4"})," ",error)),__gh(import_framer_motion.motion.button,{type:"submit",disabled:loading||!dni.trim(),whileHover:{scale:dni.trim()&&!loading?1.01:1},whileTap:{scale:dni.trim()&&!loading?.99:1},transition:{duration:.15,ease:EASE},className:"rm-grad w-full py-4 rounded-xl text-white font-semibold shadow-lg hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 transition-shadow"},loading?__gh(__gf,null,__gh(import_lucide_react.Loader2,{className:"w-5 h-5 animate-spin"})," Verificando\u2026"):__gh(__gf,null,__gh(import_lucide_react.ShieldCheck,{className:"w-5 h-5"})," Verificar y continuar"))),__gh("p",{className:"text-center text-[11px] text-zinc-400 mt-6 leading-relaxed","data-gufi-src":"page.tsx:456"},"Tratamos tu DNI/NIF \xFAnicamente para verificar tu identidad como ",esArrendador?"firmante autorizado por la propiedad":"titular del contrato","(RGPD Art. 6.1.b \u2014 ejecuci\xF3n de contrato). No se almacena ni se comparte con terceros."))}function SignScreen({data,previewMode,esArrendador,canvasRef,onPointerDown,onPointerMove,onPointerUp,onClearSignature,hasSignature,accepted,setAccepted,error,loading,onSubmit}){let canSubmit=accepted&&hasSignature,blocker=!accepted&&!hasSignature?"Firma y acepta las condiciones para continuar":accepted?hasSignature?"":"Firma en el recuadro para continuar":"Acepta las condiciones para continuar";return __gh("div",{className:"max-w-3xl mx-auto","data-gufi-src":"page.tsx:495"},__gh(BrandMark,{heading:data.documento_titulo||`Contrato ${data.contrato.codigo}`}),__gh(import_framer_motion.motion.div,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},transition:{duration:.45,ease:EASE,delay:.05},className:"bg-white rounded-3xl shadow-2xl border border-zinc-100 overflow-hidden"},previewMode&&__gh("div",{className:"text-center text-[13px] font-semibold px-4 py-2.5",style:{background:"#fff8e1",borderBottom:"1px solid #f3d98a",color:"#8a6d0f"},"data-gufi-src":"page.tsx:504"},"Previsualizaci\xF3n \xB7 este contrato todav\xEDa no est\xE1 firmado"),__gh("div",{className:"rm-doc-scroll bg-zinc-50/60 px-4 sm:px-8 py-6","data-gufi-src":"page.tsx:511"},__gh("div",{className:"contract-html bg-white rounded-2xl shadow-sm border border-zinc-100 p-6 sm:p-9 mx-auto",style:{maxWidth:720},dangerouslySetInnerHTML:{__html:data.contrato.contrato_html},"data-gufi-src":"page.tsx:512"}),__gh("div",{className:"mx-auto mt-4",style:{maxWidth:720},"data-gufi-src":"page.tsx:519"},previewMode?__gh("div",{style:{border:"1.5px dashed #cfc9ff",borderRadius:12,padding:22,textAlign:"center",color:"#6d63d6",fontSize:11,fontWeight:800,letterSpacing:1.5,textTransform:"uppercase",background:"#faf9ff"},"data-gufi-src":"page.tsx:521"},"Pendiente de firma"):__gh("div",{className:"bg-white rounded-2xl border border-zinc-100 shadow-sm p-5","data-gufi-src":"page.tsx:529"},__gh("div",{className:"text-[11px] font-extrabold tracking-[0.12em] uppercase mb-3",style:{color:ACCENT},"data-gufi-src":"page.tsx:530"},"Firma aqu\xED \xB7 ",esArrendador?"por el arrendador":"por el arrendatario"),__gh(SignatureCanvas,{canvasRef,hasSignature,onPointerDown,onPointerMove,onPointerUp,onClear:onClearSignature})))),!previewMode&&__gh(__gf,null,(esArrendador?data.firmado_arrendatario:data.firmado_arrendador)!==void 0&&__gh("div",{className:"px-6 sm:px-8 pt-5","data-gufi-src":"page.tsx:548"},__gh("div",{className:"rounded-xl px-4 py-3 text-[12.5px] leading-snug flex items-start gap-2",style:(esArrendador?data.firmado_arrendatario:data.firmado_arrendador)?{background:"#ecfdf5",color:"#065f46",border:"1px solid #a7f3d0"}:{background:"#fff8e1",color:"#8a6d0f",border:"1px solid #f3d98a"},"data-gufi-src":"page.tsx:549"},(esArrendador?data.firmado_arrendatario:data.firmado_arrendador)?__gh(import_lucide_react.CheckCircle2,{className:"w-4 h-4 mt-[1px] shrink-0"}):__gh(import_lucide_react.AlertCircle,{className:"w-4 h-4 mt-[1px] shrink-0"}),__gh("span",{"data-gufi-src":"page.tsx:556"},(esArrendador?data.firmado_arrendatario:data.firmado_arrendador)?esArrendador?"El arrendatario ya ha firmado. Con tu firma el contrato queda completo.":"El arrendador ya ha firmado. Con tu firma el contrato queda completo.":esArrendador?"El arrendatario todav\xEDa no ha firmado. Tu firma queda registrada y el contrato se completar\xE1 cuando firme la otra parte.":"La parte arrendadora todav\xEDa no ha firmado. Tu firma queda registrada y el contrato se completar\xE1 cuando firme."))),__gh("div",{className:"px-6 sm:px-8 py-5 border-t border-zinc-100","data-gufi-src":"page.tsx:568"},__gh(AppleCheckbox,{checked:accepted,onChange:v=>setAccepted(v),label:esArrendador?"He le\xEDdo y acepto las condiciones del contrato, y firmo en representaci\xF3n de la parte arrendadora.":"He le\xEDdo y acepto las condiciones del contrato de arrendamiento."})),__gh("div",{className:"px-6 sm:px-8 py-5 border-t border-zinc-100 bg-gradient-to-b from-white to-zinc-50/60 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3","data-gufi-src":"page.tsx:578"},__gh("div",{className:"text-xs text-zinc-500 sm:max-w-sm leading-relaxed","data-gufi-src":"page.tsx:579"},"Tu firma digital tiene la misma validez legal que una manuscrita (Reglamento eIDAS UE 910/2014, Ley 6/2020)."),__gh("div",{className:"flex flex-col items-stretch sm:items-end gap-1.5","data-gufi-src":"page.tsx:583"},__gh(SignButton,{onClick:onSubmit,disabled:!canSubmit,loading}),error&&__gh("p",{className:"text-xs text-rose-600 flex items-center gap-1 sm:justify-end","data-gufi-src":"page.tsx:586"},__gh(import_lucide_react.AlertCircle,{className:"w-3.5 h-3.5"})," ",error),!canSubmit&&!loading&&!error&&__gh("p",{className:"text-[11px] text-zinc-500 sm:text-right","data-gufi-src":"page.tsx:591"},blocker)))),previewMode&&__gh("div",{className:"px-6 sm:px-8 py-4 border-t border-zinc-100 text-center text-xs text-zinc-500","data-gufi-src":"page.tsx:598"},"Esto es una previsualizaci\xF3n. La firma se realiza desde el enlace que recibe el inquilino.")),__gh("p",{className:"text-center text-[11px] text-zinc-400 mt-5","data-gufi-src":"page.tsx:604"},"Powered by Gufi"))}function SignatureCanvas({canvasRef,hasSignature,onPointerDown,onPointerMove,onPointerUp,onClear}){return __gh("div",{className:`relative w-full rounded-xl overflow-hidden border ${hasSignature?"border-zinc-200":"rm-sig-pulse border-zinc-200"}`,"data-gufi-src":"page.tsx:620"},__gh("canvas",{ref:canvasRef,className:"w-full h-[130px] bg-white touch-none cursor-crosshair block",onPointerDown,onPointerMove,onPointerUp,onPointerCancel:onPointerUp,"data-gufi-src":"page.tsx:621"}),__gh(import_framer_motion.AnimatePresence,null,!hasSignature&&__gh(import_framer_motion.motion.div,{key:"hint",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25,ease:EASE},className:"absolute inset-0 flex items-center justify-center pointer-events-none"},__gh("span",{className:"text-[11px] uppercase tracking-[0.18em] font-semibold select-none text-zinc-400","data-gufi-src":"page.tsx:637"},"Dibuja tu firma con el dedo o el rat\xF3n"))),__gh(import_framer_motion.AnimatePresence,null,hasSignature&&__gh(import_framer_motion.motion.button,{type:"button",onClick:onClear,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:EASE},className:"absolute top-2 right-2 p-1.5 rounded-lg bg-white/95 border border-zinc-200 hover:bg-zinc-50 transition-colors flex items-center gap-1 text-[11px] font-medium text-zinc-600","aria-label":"Limpiar firma"},__gh(import_lucide_react.RefreshCw,{className:"w-3.5 h-3.5"})," Repetir")))}function AppleCheckbox({checked,onChange,label}){return __gh("div",{role:"checkbox","aria-checked":checked,tabIndex:0,onClick:()=>onChange(!checked),onKeyDown:e=>{(e.key===" "||e.key==="Enter")&&(e.preventDefault(),onChange(!checked))},className:"flex items-center gap-3 cursor-pointer select-none group focus:outline-none rounded-md py-1","data-gufi-src":"page.tsx:664"},__gh("div",{className:"relative flex-none w-6 h-6 rounded-md border-2 flex items-center justify-center transition-all duration-200",style:checked?{background:ACCENT,borderColor:ACCENT}:{background:"#fff",borderColor:"#d4d4d8"},"data-gufi-src":"page.tsx:670"},__gh(import_framer_motion.AnimatePresence,null,checked&&__gh(import_framer_motion.motion.span,{key:"check",initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.18,ease:EASE},className:"flex items-center justify-center"},__gh(import_lucide_react.Check,{className:"w-4 h-4 text-white",strokeWidth:3.5})))),__gh("span",{className:`text-sm leading-relaxed transition-colors duration-200 ${checked?"text-zinc-900":"text-zinc-700"}`,"data-gufi-src":"page.tsx:687"},label))}function SignButton({onClick,disabled,loading}){let isActive=!disabled&&!loading;return __gh(import_framer_motion.motion.button,{onClick,disabled:disabled||loading,whileHover:isActive?{y:-1}:void 0,whileTap:isActive?{scale:.98}:void 0,transition:{duration:.15,ease:EASE},className:`relative px-7 py-3.5 rounded-xl font-semibold inline-flex items-center justify-center gap-2 overflow-hidden transition-all duration-300 ${isActive?"text-white shadow-lg hover:shadow-xl":"text-zinc-400 bg-zinc-200 cursor-not-allowed"}`},__gh("span",{"aria-hidden":!0,className:`absolute inset-0 transition-opacity duration-300 ${isActive?"opacity-100":"opacity-0"}`,style:{background:"linear-gradient(90deg, #3F5244 0%, #8b7bff 100%)"},"data-gufi-src":"page.tsx:708"}),__gh("span",{className:"relative z-10 inline-flex items-center gap-2","data-gufi-src":"page.tsx:713"},loading?__gh(__gf,null,__gh(import_lucide_react.Loader2,{className:"w-5 h-5 animate-spin"})," Firmando\u2026"):__gh(__gf,null,__gh(import_lucide_react.CheckCircle2,{className:"w-5 h-5"})," Firmar contrato")))}function SuccessScreen({data,emailSent,clientEmail,pdfBase64,pdfFilename,completo,esArrendador}){let wasAlreadySigned=data?.firmado&&!pdfBase64,emailToShow=clientEmail||(data?.inquilino?.email??null);return __gh("div",{className:"bg-white rounded-3xl shadow-xl border border-emerald-100 p-8 max-w-md w-full mx-auto text-center relative overflow-hidden","data-gufi-src":"page.tsx:741"},__gh(import_framer_motion.motion.div,{initial:{scale:.5,rotate:-8,opacity:0},animate:{scale:1,rotate:0,opacity:1},transition:{duration:.55,ease:EASE,type:"spring",stiffness:220,damping:18},className:"w-20 h-20 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-6 relative z-10"},__gh(import_lucide_react.CheckCircle2,{className:"w-10 h-10 text-emerald-600"})),__gh(import_framer_motion.motion.h1,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35,ease:EASE,delay:.15},className:"text-2xl font-bold text-zinc-900 mb-2 relative z-10"},wasAlreadySigned?`${data?.documento_tipo==="adenda"?"Anexo":"Contrato"} ya firmado`:completo===!1?"Firma registrada":"\xA1Firma completada!"),data?.contrato&&__gh(import_framer_motion.motion.p,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35,ease:EASE,delay:.22},className:"text-zinc-500 mb-4 relative z-10"},data.documento_tipo==="adenda"?"Anexo":"Contrato"," ",__gh("strong",{"data-gufi-src":"page.tsx:762"},data.contrato.codigo),data.contrato.firma_fecha&&__gh(__gf,null," \xB7 firmado el ",formatLongDate(data.contrato.firma_fecha))),!wasAlreadySigned&&completo===!1&&__gh(import_framer_motion.motion.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35,ease:EASE,delay:.26},className:"rounded-xl px-4 py-3 mb-4 text-[12.5px] leading-snug text-left relative z-10",style:{background:"#fff8e1",color:"#8a6d0f",border:"1px solid #f3d98a"}},"Tu firma ha quedado registrada. El contrato estar\xE1 completo cuando firme"," ",esArrendador?"el arrendatario":"la parte arrendadora"," \u2014 recibir\xE1s el PDF definitivo entonces."),!wasAlreadySigned&&emailSent&&emailToShow&&__gh(import_framer_motion.motion.p,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35,ease:EASE,delay:.3},className:"text-sm text-zinc-600 mb-6 leading-relaxed relative z-10"},"Te hemos enviado el contrato firmado a ",__gh("strong",{"data-gufi-src":"page.tsx:783"},emailToShow)," con el PDF adjunto. Revisa tu bandeja de entrada (o spam)."),!wasAlreadySigned&&!emailSent&&__gh(import_framer_motion.motion.p,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35,ease:EASE,delay:.3},className:"text-sm text-zinc-500 mb-6 relative z-10"},"Descarga tu copia del contrato firmado aqu\xED abajo."),pdfBase64?__gh(import_framer_motion.motion.button,{type:"button",onClick:()=>downloadPdfFromBase64(pdfBase64,pdfFilename||"contrato.pdf"),initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35,ease:EASE,delay:.4},whileHover:{scale:1.02},whileTap:{scale:.98},className:"rm-grad inline-flex items-center gap-2 px-6 py-3 rounded-xl text-white font-semibold shadow-lg hover:shadow-xl transition-shadow relative z-10"},__gh(import_lucide_react.Download,{className:"w-5 h-5"})," Descargar PDF"):wasAlreadySigned?__gh("p",{className:"text-xs text-zinc-400 relative z-10","data-gufi-src":"page.tsx:808"},"Pide a Rumar Flats el PDF firmado si lo necesitas."):null)}function BrandMark({heading}){return __gh(import_framer_motion.motion.div,{initial:{opacity:0,y:-12},animate:{opacity:1,y:0},transition:{duration:.4,ease:EASE},className:"text-center mb-6"},__gh("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center mx-auto mb-3 shadow-lg",style:{background:"linear-gradient(135deg, #3F5244 0%, #8b7bff 100%)"},"data-gufi-src":"page.tsx:825"},__gh(import_lucide_react.FileSignature,{className:"w-8 h-8 text-white"})),__gh("div",{className:"text-xl font-extrabold tracking-tight text-zinc-900","data-gufi-src":"page.tsx:829"},"Rumar ",__gh("span",{style:{color:ACCENT},"data-gufi-src":"page.tsx:830"},"Flats")),__gh("p",{className:"text-zinc-500 mt-1 text-sm","data-gufi-src":"page.tsx:832"},heading||"Firma de contrato de arrendamiento"))}function ErrorScreen({title,message}){return __gh("div",{className:"min-h-[100dvh] bg-gradient-to-br from-rose-50 via-white to-orange-50 flex items-center justify-center p-4","data-gufi-src":"page.tsx:839"},__gh(import_framer_motion.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,ease:EASE},className:"bg-white rounded-3xl shadow-xl border border-rose-100 p-8 max-w-md w-full text-center"},__gh("div",{className:"w-16 h-16 rounded-2xl bg-rose-100 flex items-center justify-center mx-auto mb-4","data-gufi-src":"page.tsx:845"},__gh(import_lucide_react.AlertCircle,{className:"w-8 h-8 text-rose-600"})),__gh("h1",{className:"text-xl font-bold text-zinc-900 mb-2","data-gufi-src":"page.tsx:848"},title),__gh("p",{className:"text-zinc-500","data-gufi-src":"page.tsx:849"},message)))}function Layout({children}){return __gh(__gf,null,__gh("style",{"data-gufi-src":"page.tsx:858"},` @keyframes rm-sig-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(63,82,68, 0.0); } 50% { box-shadow: 0 0 0 4px rgba(63,82,68, 0.14); } } .rm-sig-pulse { animation: rm-sig-pulse 2.2s ease-in-out infinite; } .rm-grad { background: linear-gradient(90deg, #3F5244 0%, #8b7bff 100%); } .rm-input:focus { border-color: #3F5244; box-shadow: 0 0 0 3px rgba(63,82,68, 0.15); } .rm-page-bg { background: linear-gradient(135deg, #f6f5ff 0%, #ffffff 45%, #f3f1ff 100%); } .rm-doc-scroll { max-height: 66vh; overflow-y: auto; scroll-behavior: smooth; } /* Estilos del contrato_html renderizado (clases que emite el ERP) */ .contract-html { color: #1a1a2e; font-size: 14px; line-height: 1.6; } .contract-html .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 18px; border-bottom: 2px solid #ece9ff; margin-bottom: 8px; } .contract-html .brand { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: #1a1a2e; } .contract-html .brand span { color: #3F5244; } .contract-html .muted { color: #6b7280; font-size: 12.5px; line-height: 1.5; } .contract-html h1 { font-size: 18px; font-weight: 700; color: #1a1a2e; margin: 0; } .contract-html h3 { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #3F5244; margin: 22px 0 8px; } .contract-html p { margin: 10px 0; } .contract-html table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13.5px; } .contract-html th { text-align: left; background: #f5f3ff; color: #4c3fd8; font-weight: 700; padding: 9px 12px; border: 1px solid #ece9ff; } .contract-html td { padding: 9px 12px; border: 1px solid #eef0f4; vertical-align: top; } .contract-html .tot { font-weight: 800; color: #1a1a2e; } .contract-html strong { color: #1a1a2e; } `),__gh("div",{className:"min-h-[100dvh] rm-page-bg py-6 sm:py-10 px-3 sm:px-4 flex items-start justify-center","data-gufi-src":"page.tsx:884"},__gh("div",{className:"w-full","data-gufi-src":"page.tsx:885"},children)))}var stdin_default=FirmaContratoRumar;