PageSourceSearch

https://start.firstbreaklabs.com/assets/PublishingAgreementSigningPage-DdFM0qDq.js

js firstbreaklabs.com collected 2026-10-08 01:58:52 UTC 19,781 bytes, 9 lines download raw bytes

1import{q as _e,k as Se,u as ke,r as t,s as o,j as e,B as E,C as se,f as le,t as L,L as Pe}from"./index-BKLWdUpX.js";import{I as q}from"./input-Dne51GHv.js";import{L as b}from"./label-C_F-p37H.js";import{C as Ce}from"./checkbox-Bi2lcenk.js";import{C,b as F}from"./card-CgJbgVf0.js";import{S as Fe}from"./separator-CsefkgZm.js";import{B as H}from"./badge-Bkfr2wzE.js";import{S as te}from"./skeleton-CgqkqNsa.js";import{a as De}from"./pdfGenerator-D-Z1UW11.js";import{S as Ee}from"./SignaturePad-zXK0gtgn.js";import{C as ae}from"./circle-alert-BnrdJm0u.js";import{F as y}from"./file-pen-line-HdIt7sE7.js";import{C as re}from"./clock-pTqPL1WU.js";import{S as ne}from"./shield-EXxds9vJ.js";import{M as Le}from"./mail-BZdWwxhp.js";import{F as ie}from"./file-text-Bk8Yu8NL.js";import{D as Te}from"./download-DZKcnHSS.js";import"./index-QmFupuZq.js";import"./check-BO86AMmH.js";import"./jspdf.es.min-DiAcCFPm.js";import"./pencil-DiWD7Er-.js";import"./trash-2-BjUj9xDl.js";import"./undo-2-UpjClu_W.js";const h={short_name:"First Break Labs",copyright:"© 2024 FirstBlood Technologies, Inc. dba First Break Labs. All rights reserved."};function D({token:n}){return n?e.jsx(Pe,{to:`/login?next=${encodeURIComponent(`/sign/agreement/${n}`)}`,className:"text-sm text-[#7ac142] hover:underline",children:"Sign in"}):null}function Ae({storagePath:n}){const[g,w]=t.useState(!1),T=async()=>{if(n){w(!0);try{const{data:f,error:v}=await o.storage.from("legal-documents").download(n);if(v)throw v;const _=URL.createObjectURL(f),c=window.document.createElement("a");c.href=_,c.download=n.split("/").pop()||"signed-agreement.pdf",window.document.body.appendChild(c),c.click(),window.document.body.removeChild(c),URL.revokeObjectURL(_)}catch(f){console.error("Download error:",f),L.error("Failed to download the signed agreement.")}finally{w(!1)}}};return n?e.jsx(E,{onClick:T,disabled:g,className:"gap-2 bg-emerald-500 hover:bg-emerald-600 text-white px-6 py-5 text-base font-semibold shadow-lg",children:g?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"h-5 w-5 animate-spin"}),"Downloading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"h-5 w-5"}),"Download Signed Agreement (PDF)"]})}):null}function is(){const{token:n}=_e(),g=Se(),{user:w,isAdmin:T,isLoading:f,profileLoading:v}=ke(),[_,c]=t.useState(!0),[Y,M]=t.useState(!1),[s,ce]=t.useState(null),[p,A]=t.useState(null),[de,z]=t.useState(!1),[S,me]=t.useState(!1),[oe,Z]=t.useState(null),[x,G]=t.useState(null),[xe,B]=t.useState(!1),[W,ge]=t.useState(null),[ue,J]=t.useState(null),[k,K]=t.useState(""),[P,he]=t.useState(""),[U,fe]=t.useState(""),[R,pe]=t.useState(!1),[I,je]=t.useState(!1),[u,Ne]=t.useState("draw"),[Q,be]=t.useState(""),[V,ye]=t.useState(!0);t.useEffect(()=>{n&&X()},[n]);const $=!!(w&&!T&&!f&&!v);t.useEffect(()=>{if(!$||!s?.id||p||S)return;let a=!1;return o.from("documents").select("game_id").eq("id",s.id).maybeSingle().then(({data:i})=>{if(a)return;if(!i){Z(!1);return}const r=i.game_id?`/portal/documents?game=${i.game_id}`:"/portal/documents";Z(r),g(r,{replace:!0})}),()=>{a=!0}},[$,s,p,S,g]),t.useEffect(()=>()=>{x?.startsWith("blob:")&&URL.revokeObjectURL(x)},[x]);const X=async()=>{try{const{data:a,error:i}=await o.rpc("get_agreement_by_token",{p_signing_token:n});if(i)throw i;const r=a;if(!r.success){A(r.message||"This signing link is invalid or has expired."),c(!1);return}if(!r.document){A("This signing link is invalid or has expired."),c(!1);return}if(ce(r.document),r.document.status==="signed"&&(z(!0),r.document.file_path&&J(r.document.file_path)),r.is_expired&&me(!0),r.document.status!=="signed"){const d=r.document.template_file_path||r.document.signature_data?.template_file_path;if(console.log("[Agreement] Template file path:",d),d){const{data:j,error:N}=await o.storage.from("legal-documents").download(d);if(N){console.error("[Agreement] Storage download failed:",N.message,"| Path:",d);const{data:m,error:l}=await o.storage.from("legal-documents").createSignedUrl(d,3600);l?(console.error("[Agreement] Signed URL also failed:",l.message),B(!0)):m?.signedUrl&&G(m.signedUrl)}else if(j){const m=URL.createObjectURL(j);G(m),ge(await j.arrayBuffer())}}
1else console.error("[Agreement] No template file path found in document"),B(!0)}}catch(a){console.error("Error loading agreement:",a),A("Failed to load the agreement. Please try again or contact support.")}finally{c(!1)}},we=async()=>{const a=u==="type"?Q:k.trim();if(!s||!a||V||!R){L.error("Please complete all required fields including your signature");return}M(!0);try{const i=await fetch("https://api.ipify.org?format=json").then(l=>l.json()).then(l=>l.ip).catch(()=>"unknown"),r=navigator.userAgent,d=u==="draw"?Q:null,{data:j,error:N}=await o.rpc("sign_agreement_document",{p_signing_token:n,p_signer_full_name:a,p_signer_company:P.trim()||null,p_signer_title:U.trim()||null,p_ip_address:i,p_user_agent:r,p_signature_type:u,p_signature_image_data:d});if(N)throw N;const m=j;if(!m.success)throw new Error(m.error||"Failed to sign document");if(L.success("Publishing agreement signed successfully!"),W)try{const l=await De(W,{recipient_name:s.signature_data?.recipient_name||"",recipient_email:s.signature_data?.recipient_email||"",signer_full_name:a,signer_company:P.trim()||void 0,signer_title:U.trim()||void 0,signature_type:u,signature_image_data:d||void 0,signed_at:new Date().toISOString(),ip_address:i,sent_at:s.signature_data?.sent_at}),ve=`signed-agreement-${(P.trim()||a).replace(/[^a-zA-Z0-9]/g,"-")}-${new Date().toISOString().split("T")[0]}.pdf`,O=`agreements/${m.document_id||s.id}/${ve}`,{error:ee}=await o.storage.from("legal-documents").upload(O,l,{contentType:"application/pdf",upsert:!0});ee?console.error("PDF upload error:",ee):(J(O),await o.rpc("update_agreement_file_path",{p_signing_token:n,p_file_path:O}))}catch(l){console.error("PDF generation/upload error:",l)}z(!0),X()}catch(i){console.error("Error signing agreement:",i),L.error("Failed to sign agreement. Please try again.")}finally{M(!1)}};return _?e.jsx("div",{className:"min-h-screen bg-[#f5f5f5]",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-12",children:[e.jsx(te,{className:"h-12 w-64 mb-4"}),e.jsx(te,{className:"h-[800px]"})]})}):$&&s&&!p&&!S&&oe!==!1?e.jsx("div",{className:"marketing flex min-h-dvh items-center justify-center bg-black text-white",children:e.jsx("p",{className:"text-sm text-white/40",children:"Opening portal"})}):p?e.jsx("div",{className:"min-h-screen bg-[#f5f5f5] flex items-center justify-center",children:e.jsx(C,{className:"max-w-md shadow-lg",children:e.jsxs(F,{className:"pt-8 pb-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-red-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(ae,{className:"h-8 w-8 text-red-500"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Unable to Load Document"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:p}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4",children:[e.jsx(D,{token:n}),e.jsx(E,{variant:"outline",onClick:()=>g("/"),children:"Return Home"})]})]})})}):de?e.jsxs("div",{className:"min-h-screen bg-[#f5f5f5]",children:[e.jsx("div",{className:"bg-[#1a1a2e] text-white py-4",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center font-bold text-lg",children:"FB"}),e.jsx("span",{className:"font-semibold",children:h.short_name})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(D,{token:n}
1),e.jsxs(H,{className:"bg-emerald-500 hover:bg-emerald-500",children:[e.jsx(se,{className:"h-3 w-3 mr-1"}),"Completed"]})]})]})}),e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-16 text-center",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-6",children:e.jsx(se,{className:"h-10 w-10 text-emerald-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Agreement Signed Successfully"}),e.jsxs("p",{className:"text-gray-600 mb-8",children:["This Publishing Agreement has been executed.",s?.game?.title&&e.jsxs("span",{className:"block mt-1 text-sm",children:["Game: ",s.game.title]})]}),e.jsx(C,{className:"text-left mb-8 shadow-lg bg-white border",children:e.jsxs(F,{className:"pt-6 pb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(y,{className:"h-5 w-5 text-emerald-500"}),e.jsx("h3",{className:"font-semibold text-gray-800",children:"Signature Record"})]}),e.jsxs("div",{className:"bg-gray-100 rounded-lg p-4 mb-6 border border-gray-200",children:[e.jsx("p",{className:"text-xs text-gray-600 uppercase tracking-wide mb-2",children:"Electronic Signature"}),e.jsx("p",{className:"font-signature text-2xl text-emerald-700",children:s?.signature_data?.signer_full_name}),s?.signature_data?.signer_company&&e.jsxs("p",{className:"text-sm text-gray-700 mt-1",children:[s.signature_data.signer_company,s?.signature_data?.signer_title&&` • ${s.signature_data.signer_title}`]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-emerald-50 rounded-lg border border-emerald-200",children:[e.jsx(re,{className:"h-5 w-5 text-emerald-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-emerald-700 font-medium uppercase tracking-wide",children:"Signed"}),e.jsx("p",{className:"text-sm font-medium text-gray-800",children:s?.signature_data?.signed_at?new Date(s.signature_data.signed_at).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})+" at "+new Date(s.signature_data.signed_at).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",timeZoneName:"short"}):"Date not recorded"})]})]}),e.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600",children:[e.jsx(ne,{className:"h-3 w-3"}),e.jsxs("span",{children:["Digitally verified • IP: ",s?.signature_data?.ip_address?.replace(/\.\d+$/,".***")||"***"]})]})})]})}),e.jsx(Ae,{storagePath:ue}),e.jsx("p",{className:"text-xs text-gray-400 mt-8",children:h.copyright})]}),e.jsx("style",{children:`
2          .font-signature {
3            font-family: 'Brush Script MT', 'Segoe Script', 'Bradley Hand', cursive;
4          }
5        `})]}):S?e.jsxs("div",{className:"min-h-screen bg-[#f5f5f5]",children:[e.jsx("div",{className:"bg-[#1a1a2e] text-white py-4",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center font-bold text-lg",children:"FB"}),e.jsx("span",{className:"font-semibold",children:h.short_name})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(D,{token:n}),e.jsxs(H,{variant:"outline",className:"border-red-500 text-red-500",children:[e.jsx(ae,{className:"h-3 w-3 mr-1"}),"Expired"]})]})]})}),e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-16 text-center",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-amber-100 flex items-center justify-center mx-auto mb-6",children:e.jsx(re,{className:"h-10 w-10 text-amber-500"})}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Signing Link Expired"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"This publishing agreement signing link has expired. Please request a new one."}),e.jsx(C,{className:"text-left mb-8",children:e.jsxs(F,{className:"pt-6",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Need to sign this agreement?"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Please contact First Break Labs to request a new signing link:"}),e.jsx("div",{className:"space-y-2 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg",children:[e.jsx(Le,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("a",{href:"mailto:[email protected]?subject=Request%20New%20Agreement%20Signing%20Link",className:"text-primary hover:underline",children:"[email protected]"})]})})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h.copyright})]})]}):e.jsxs("div",{className:"min-h-screen bg-[#f5f5f5]",children:[e.jsx("div",{className:"bg-[#1a1a2e] text-white py-4 sticky top-0 z-50",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center font-bold text-lg",children:"FB"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:h.short_name}),e.jsx("p",{className:"text-xs text-gray-400",children:"Document Signing"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(D,{token:n}),e.jsxs("span",{className:"text-sm text-gray-300",children:["For: ",s?.signature_data?.recipient_name]}),e.jsxs(H,{variant:"outline",className:"border-yellow-500 text-yellow-500",children:[e.jsx(y,{className:"h-3 w-3 mr-1"}),"Awaiting Signature"]})]})]})}),e.jsx("div",{className:"bg-white border-b shadow-sm",children:e.jsx("div",{className:"max-w-5xl mx-auto px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-8 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-emerald-500 text-white flex items-center justify-center text-xs font-semibold",children:"1"}),e.jsx("span",{className:"font-medium text-gray-900",children:"Review Agreement"})]}),e.jsx("div",{className:"h-px bg-gray-300 flex-1 max-w-[60px]"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-xs font-semibold ${I?"bg-emerald-500 text-white":"bg-gray-200 text-gray-500"}`,children:"2"}),e.jsx("span",{className:I?"font-medium text-gray-900":"text-gray-500",children:"Sign"})]}),e.jsx("div",{className:"h-px bg-gray-300 flex-1 max-w-[60px]"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-gray-200 text-gray-500 flex items-center justify-center text-xs font-semibold",children:"3"}),e.jsx("span",{className:"text-gray-500",children:"Complete"})]})]})})}),e.jsx("div",{className:"max-w-5xl mx-auto px-4 py-8",children:e.jsxs("div",{className:"grid lg:grid-cols-[1fr,380px] gap-8",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"bg-white rounded-lg shadow-lg overflow-hidden",children:[e.jsx("div",{className:"bg-gray-50 border-b px-8 py-4 flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ie,{className:"h-5 w-5 text-gray-500"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-gray-700",children:s?.title||"Publishing Agreement"}),s?.game?.title&&e.jsx("p",{className:"text-xs text-gray-500",children:s.game.title})]})]})}),e.jsx("div",{className:"relative",style:{height:"800px"},children:x&&!xe?e.jsx("iframe",{src:x,className:"w-full h-full border-0",title:"Publishing Agreement PDF",onError:()=>B(!0)}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-amber-100 flex items-center justify-center mb-4",children:e.jsx(ie,{className:"h-8 w-8 text-amber-500"})}),e.jsx("h3",{className:"font-semibold text-gray-700 mb-2",children:"Unable to Display Agreement"}),e.jsx("p",{className:"text-sm text-gray-500 max-w-sm",children:"The agreement PDF could not be loaded. Please contact your publisher representative for assistance."}),x&&e.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"mt-4 text-sm text-emerald-600 hover:underline",children:"Open PDF in new tab"})]})})]}),!I&&e.jsx("div",{className:"flex justify-center mt-4",children:e.jsxs(E,{variant:"outline",className:"gap-2",onClick:()=>je(!0),children:[e.jsx(y,{className:"h-4 w-4"}),"Continue to Sign"]})})]}),e.jsx("div",{className:"lg:sticky lg:top-32 lg:self-start",children:e.jsx(C,{className:"shadow-lg border-2 border-emerald-100",children:e.jsxs(F,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-100 flex items-center justify-center",children:e.jsx(y,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Sign Agreement"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the fields below"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"company",className:"text-xs font-medium text-gray-600",children:"Your Company / Studio Name"}),e.jsx(q,{id:"company",placeholder:"Enter company name",value:P,onChange:a=>he(a.target.value),className:"border-gray-200 focus:border-emerald-500 focus:ring-emerald-500"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"title",className:"text-xs font-medium text-gray-600",children:["Your Title ",e.jsx("span",{className:"text-gray-400",children:"(optional)"})]}),e.jsx(q,{id:"title",placeholder:"e.g., CEO, Founder",value:U,onChange:a=>fe(a.target.value),className:"border-gray-200 focus:border-emerald-500 focus:ring-emerald-500"})]}),e.jsx(Fe,{className:"my-4"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"text-xs font-medium text-gray-600",children:["Your Signature ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ee,{initialName:k,onSignatureChange:({type:a,data:i,isEmpty:r})=>{Ne(a),be(i),ye(r),a==="type"&&K(i)}})]}),u==="draw"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"fullName",className:"text-xs font-medium text-gray-600",children:["Full Legal Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(q,{id:"fullName",placeholder:"Your full legal name",value:k,onChange:a=>K(a.target.value),className:"border-gray-200 focus:border-emerald-500 focus:ring-emerald-500"})]}),e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-gray-50 rounded-lg mt-4",children:[e.jsx(Ce,{id:"agree",checked:R,onCheckedChange:a=>pe(a),className:"mt-0.5 border-gray-300 data-[state=checked]:bg-emerald-500 data-[state=checked]:border-emerald-500"}),e.jsx(b,{htmlFor:"agree",className:"text-sm leading-relaxed cursor-pointer text-gray-600",children:"I have reviewed the publishing agreement and agree that my signature constitutes my legal electronic signature accepting the terms."})]}),e.jsx(E,{className:"w-full bg-emerald-500 hover:bg-emerald-600 text-white py-6 text-base font-semibold shadow-lg",onClick:we,disabled:V||u==="draw"&&!k.trim()||!R||Y,children:Y?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"h-5 w-5 mr-2 animate-spin"}),"Signing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"h-5 w-5 mr-2"}),"Sign & Complete"]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-gray-400 mt-4",children:[e.jsx(ne,{className:"h-3 w-3"}),e.jsx("span",{children:"Secured & encrypted"})]})]})]})})})]})}),e.jsx("div",{className:"border-t bg-white py-6 mt-12",children:e.jsx("div",{className:"max-w-5xl mx-auto px-4 text-center",children:e.jsx("p",{className:"text-xs text-gray-400",children:h.copyright})})}),e.jsx("style",{children:`
6        .font-signature {
7          font-family: 'Brush Script MT', 'Segoe Script', 'Bradley Hand', cursive;
8        }
9      `})]})}
9export{is as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.