'; // Convert HTML to Blob const blob = new Blob([htmlContent], { type: 'application/vnd.ms-word;charset=utf-8' }); // Create download link and trigger download const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = `${formData.fileName || 'Revenue-Based-Financing-Agreement'}.doc`; document.body.appendChild(link); link.click(); document.body.removeChild(link); console.log("Document generated and download triggered"); } catch (error) { console.error("Error generating Word document:", error); alert("Error generating Word document. Please try again or use the copy option."); } }; /* -------- Main Application Component -------- */ const { useState, useEffect, useRef } = React; const Icon = ({ name, children }) => { return ( {children} ); }; const RevenueBasedFinancingGenerator = () => { // Tab configuration const tabs = [ { id: 'parties', label: 'Parties' }, { id: 'investment', label: 'Investment Terms' }, { id: 'repayment', label: 'Repayment Terms' }, { id: 'security', label: 'Security & Covenants' }, { id: 'termination', label: 'Default & Termination' }, ]; // State for current tab const [currentTab, setCurrentTab] = useState(0); // State for form data const [formData, setFormData] = useState({ // Parties Tab companyName: '', companyType: 'Delaware Corporation', companyAddress: '', companyRepName: '', companyRepTitle: 'CEO', investorName: '', investorType: 'Individual', investorAddress: '', // Investment Terms Tab investmentAmount: '100,000', fundingDate: '', investmentPurpose: 'general working capital and business growth', returnMultiple: '1.5', // Repayment Terms Tab revenuePercentage: '8', minMonthlyPayment: '2,000', paymentFrequency: 'Monthly', paymentStartDate: '', revenueDefinition: 'all income, revenue, receipts, receivables and proceeds from sales', excludedRevenue: '', // Security & Covenants Tab collateral: 'None', personalGuarantee: false, financialReporting: 'Monthly', restrictedActivities: true, additionalDebt: true, materialChanges: true, // Default & Termination Tab cureDefault: true, cureTime: '15', accelerationPayment: true, earlySatisfaction: '90', disputeResolution: 'Arbitration', lawGoverning: 'California', // Document Info documentTitle: 'Revenue-Based Financing Agreement', fileName: 'Revenue-Based-Financing-Agreement', }); // State to track what was last changed const [lastChanged, setLastChanged] = useState(null); // Ref for preview content div const previewRef = useRef(null); // Handle input changes const handleChange = (e) => { const { name, value, type, checked } = e.target; // Record what field was changed for highlighting setLastChanged(name); // Update form data setFormData(prev => ({ ...prev, [name]: type === 'checkbox' ? checked : value })); }; // Navigation functions const nextTab = () => { if (currentTab < tabs.length - 1) { setCurrentTab(currentTab + 1); } }; const prevTab = () => { if (currentTab > 0) { setCurrentTab(currentTab - 1); } }; const goToTab = (index) => { setCurrentTab(index); }; // Generate the document text based on form data const generateDocumentText = () => { const { companyName, companyType, companyAddress, companyRepName, companyRepTitle, investorName, investorType, investorAddress, investmentAmount, fundingDate, investmentPurpose, returnMultiple, revenuePercentage, minMonthlyPayment, paymentFrequency, paymentStartDate, revenueDefinition, excludedRevenue, collateral, personalGuarantee, financialReporting, restrictedActivities, additionalDebt, materialChanges, cureDefault, cureTime, accelerationPayment, earlySatisfaction, disputeResolution, lawGoverning } = formData; // Format today's date const today = new Date(); const formattedDate = today.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); // Calculate full repayment amount const investmentAmountNumeric = parseFloat(investmentAmount.replace(/,/g, '')); const returnMultipleNumeric = parseFloat(returnMultiple); const fullRepaymentAmount = (investmentAmountNumeric * returnMultipleNumeric).toLocaleString(); let documentText = `REVENUE-BASED FINANCING AGREEMENT THIS REVENUE-BASED FINANCING AGREEMENT (the "Agreement") is made and entered into as of ${fundingDate || formattedDate} (the "Effective Date"). BETWEEN: ${companyName || '[COMPANY NAME]'}, a ${companyType} with its principal place of business at ${companyAddress || '[COMPANY ADDRESS]'} (the "Company"), represented by ${companyRepName || '[NAME]'}, its ${companyRepTitle} AND ${investorName || '[INVESTOR NAME]'}, a ${investorType} with an address at ${investorAddress || '[INVESTOR ADDRESS]'} (the "Investor"). RECITALS: WHEREAS, the Company is seeking financing to fund ${investmentPurpose}; WHEREAS, the Investor is willing to provide such financing in exchange for a share of the Company's future revenues; NOW, THEREFORE, in consideration of the mutual covenants, terms, and conditions set forth herein, and for other good and valuable consideration, the receipt and sufficiency of which are hereby acknowledged, the parties agree as follows: 1. DEFINITIONS Unless otherwise indicated in this Agreement, the following terms shall have the following meanings: 1.1. "Funding Amount" means the sum of $${investmentAmount} to be provided by the Investor to the Company pursuant to this Agreement. 1.2. "Revenue" means ${revenueDefinition || 'all income, revenue, receipts, receivables and proceeds from sales'} of the Company.${excludedRevenue ? `\n\n1.3. "Excluded Revenue" means ${excludedRevenue}.` : ''} 1.${excludedRevenue ? '4' : '3'}. "Return Cap" means $${fullRepaymentAmount}, which equals ${returnMultiple}x the Funding Amount. 1.${excludedRevenue ? '5' : '4'}. "Revenue Share Percentage" means ${revenuePercentage}% of Revenue. 2. FUNDING 2.1. Funding. Subject to the terms and conditions of this Agreement, the Investor shall provide the Funding Amount to the Company on ${fundingDate || 'the Effective Date'} (the "Funding Date"). 2.2. Use of Proceeds. The Company shall use the Funding Amount solely for ${investmentPurpose} and for no other purpose without the prior written consent of the Investor. 3. REVENUE SHARE PAYMENTS 3.1. Revenue Share. In consideration of the Funding Amount, the Company agrees to pay to the Investor the Revenue Share Percentage until the Investor has received an aggregate amount equal to the Return Cap. 3.2. Payment Frequency. The Company shall make payments to the Investor on a ${paymentFrequency} basis, beginning on ${paymentStartDate || 'the 15th day of the month following the Funding Date'} and continuing until the Return Cap has been reached. 3.3. Minimum Payments. Regardless of the Revenue earned by the Company in any given payment period, the Company shall pay the Investor a minimum of $${minMonthlyPayment} per ${paymentFrequency.toLowerCase() === 'monthly' ? 'month' : paymentFrequency.toLowerCase() === 'quarterly' ? 'quarter' : 'period'} until the Return Cap has been reached. 3.4. Payment Method. All payments shall be made by electronic funds transfer to an account designated by the Investor. 3.5. Prepayment. The Company may prepay the remaining balance of the Return Cap at any time. If the Company prepays the entire remaining balance within ${earlySatisfaction} days of the Funding Date, the Return Cap will be reduced by 10%. 4. INFORMATION RIGHTS AND COVENANTS 4.1. Financial Reporting. The Company shall provide the Investor with ${financialReporting.toLowerCase()} financial statements, including a balance sheet, income statement, and statement of cash flows, within 15 days after the end of each ${financialReporting.toLowerCase() === 'monthly' ? 'month' : financialReporting.toLowerCase() === 'quarterly' ? 'quarter' : 'year'}. 4.2. Revenue Reporting. Along with each payment, the Company shall provide a detailed calculation of Revenue for the applicable period. 4.3. Access to Records. The Investor shall have the right, upon reasonable notice, to audit the Company's books and records to verify the calculation of Revenue and payments made under this Agreement. ${restrictedActivities ? `4.4. Restricted Activities. Without the prior written consent of the Investor, the Company shall not: ` : ''}${additionalDebt ? `\n (a) Incur any additional debt or financial obligations exceeding $50,000;` : ''}${materialChanges ? `\n (b) Make any material changes to its business model or operations;` : ''}${(additionalDebt || materialChanges) ? `\n (c) Sell, transfer, or otherwise dispose of any material assets outside the ordinary course of business;` : ''}${(additionalDebt || materialChanges) ? `\n (d) Enter into any merger, consolidation, or similar transaction;` : ''} 5. SECURITY${collateral !== 'None' ? ` 5.1. Collateral. As security for the Company's obligations under this Agreement, the Company hereby grants to the Investor a security interest in ${collateral}.` : ''} ${personalGuarantee ? `5.${collateral !== 'None' ? '2' : '1'}. Personal Guarantee. The obligations of the Company under this Agreement shall be personally guaranteed by the Company's principal shareholders or officers as set forth in a separate guarantee agreement.` : ''} 6. DEFAULT AND REMEDIES 6.1. Events of Default. The occurrence of any of the following shall constitute an event of default under this Agreement: (a) Failure to make any payment when due; (b) Breach of any representation, warranty, or covenant; (c) Insolvency, bankruptcy, or similar proceedings; (d) Material adverse change in the Company's business or financial condition; (e) Change of control of the Company without prior written consent. ${cureDefault ? `6.2. Cure Period. Following an event of default, the Company shall have ${cureTime} days to cure such default.` : ''} ${accelerationPayment ? `6.${cureDefault ? '3' : '2'}. Acceleration. Upon an uncured event of default, the Investor may declare all remaining payments up to the Return Cap immediately due and payable.` : ''} 7. MISCELLANEOUS 7.1. Governing Law. This Agreement shall be governed by and construed in accordance with the laws of the State of ${lawGoverning}. 7.2. Dispute Resolution. Any dispute arising out of or relating to this Agreement shall be resolved through ${disputeResolution === 'Arbitration' ? 'binding arbitration administered by the American Arbitration Association in accordance with its Commercial Arbitration Rules' : 'litigation in the courts of the State of ' + lawGoverning}. 7.3. Entire Agreement. This Agreement constitutes the entire agreement between the parties with respect to the subject matter hereof and supersedes all prior and contemporaneous agreements and understandings, whether oral or written. 7.4. Amendments. This Agreement may only be amended, modified, or supplemented by an agreement in writing signed by each party hereto. 7.5. Notices. All notices must be in writing and sent to the addresses specified in this Agreement. 7.6. Assignment. Neither party may assign any of its rights or delegate any of its obligations under this Agreement without the prior written consent of the other party. 7.7. Severability. If any term or provision of this Agreement is invalid, illegal, or unenforceable, the remainder of this Agreement shall remain in effect. 7.8. Counterparts. This Agreement may be executed in multiple counterparts, each of which shall be deemed an original, but all of which together shall constitute one and the same instrument. IN WITNESS WHEREOF, the parties hereto have executed this Agreement as of the Effective Date. COMPANY: ${companyName || '[COMPANY NAME]'} By: ________________________ Name: ${companyRepName || '[NAME]'} Title: ${companyRepTitle} INVESTOR: ${investorName || '[INVESTOR NAME]'} By: ________________________ Name: ${investorName || '[NAME]'} Title: ${investorType === 'Individual' ? '' : '[TITLE]'}`; return documentText; }; // Generate document text const documentText = generateDocumentText(); // Function to determine which section to highlight based on the tab and last changed field const getSectionToHighlight = () => { if (!lastChanged) return null; // Define the mapping of fields to sections in the document const fieldToSectionMap = { // Parties Tab companyName: /BETWEEN:\s*\n\s*(?:.*?)(?=\s*AND)/s, companyType: /BETWEEN:\s*\n\s*(?:.*?)(?=\s*AND)/s, companyAddress: /BETWEEN:\s*\n\s*(?:.*?)(?=\s*AND)/s, companyRepName: /BETWEEN:\s*\n\s*(?:.*?)(?=\s*AND)/s, companyRepTitle: /BETWEEN:\s*\n\s*(?:.*?)(?=\s*AND)/s, investorName: /AND\s*\n\s*(?:.*?)(?=\s*RECITALS)/s, investorType: /AND\s*\n\s*(?:.*?)(?=\s*RECITALS)/s, investorAddress: /AND\s*\n\s*(?:.*?)(?=\s*RECITALS)/s, // Investment Terms Tab investmentAmount: /1\.1\. "Funding Amount".*?(\$[0-9,]+)/s, fundingDate: /2\.1\. Funding.*?on\s+(.*?)\s+\(the/s, investmentPurpose: /WHEREAS, the Company is seeking financing to fund (.*?);/s, returnMultiple: /1\.[0-9]\. "Return Cap".*?equals\s+([0-9.]+)x/s, // Repayment Terms Tab revenuePercentage: /1\.[0-9]\. "Revenue Share Percentage".*?([0-9.]+)%/s, minMonthlyPayment: /3\.3\. Minimum Payments.*?\$([0-9,]+)\s+per/s, paymentFrequency: /3\.2\. Payment Frequency.*?on a\s+(.*?)\s+basis/s, paymentStartDate: /3\.2\. Payment Frequency.*?beginning on\s+(.*?)\s+and/s, revenueDefinition: /1\.2\. "Revenue" means\s+(.*?)\s+of the Company/s, excludedRevenue: /1\.3\. "Excluded Revenue".*?(.*?)(?=\.)/s, // Security & Covenants Tab collateral: /5\.1\. Collateral.*?interest in\s+(.*?)(?=\.)/s, personalGuarantee: /5\.[0-9]\. Personal Guarantee.*?guaranteed by\s+(.*?)(?=\.)/s, financialReporting: /4\.1\. Financial Reporting.*?provide the Investor with\s+(.*?)\s+financial/s, restrictedActivities: /4\.4\. Restricted Activities.*?shall not:/s, additionalDebt: /\(a\) Incur any additional debt or financial obligations/s, materialChanges: /\(b\) Make any material changes to its business model/s, // Default & Termination Tab cureDefault: /6\.2\. Cure Period.*?shall have\s+([0-9]+)\s+days/s, cureTime: /6\.2\. Cure Period.*?shall have\s+([0-9]+)\s+days/s, accelerationPayment: /6\.[0-9]\. Acceleration.*?immediately due and payable/s, earlySatisfaction: /3\.5\. Prepayment.*?within\s+([0-9]+)\s+days/s, disputeResolution: /7\.2\. Dispute Resolution.*?resolved through\s+(.*?)(?=\.)/s, lawGoverning: /7\.1\. Governing Law.*?laws of the State of\s+(.*?)(?=\.)/s, }; return fieldToSectionMap[lastChanged]; }; // Function to create a highlighted version of the text const createHighlightedText = () => { const sectionToHighlight = getSectionToHighlight(); if (!sectionToHighlight) return documentText; return documentText.replace(sectionToHighlight, match => `${match}` ); }; // Create highlightable content const highlightedText = createHighlightedText(); // Effect to scroll to highlighted text useEffect(() => { if (previewRef.current) { const highlightedElement = previewRef.current.querySelector('.highlighted-text'); if (highlightedElement) { highlightedElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); } } }, [highlightedText]); // Copy to clipboard function const copyToClipboard = () => { try { navigator.clipboard.writeText(documentText); alert("Document copied to clipboard!"); } catch (error) { console.error("Failed to copy text: ", error); alert("Failed to copy text. Please try again or use the download option."); } }; // Download MS Word document const downloadAsWord = () => { try { console.log("Download MS Word button clicked"); if (!documentText) { console.error("Document text is empty"); alert("Cannot generate document - text is empty. Please check the form data."); return; } window.generateWordDoc(documentText, { documentTitle: formData.documentTitle, fileName: formData.fileName }); } catch (error) { console.error("Error in downloadAsWord:", error); alert("Error generating Word document. Please try again or use the copy option."); } }; // Open Calendly const openCalendly = () => { try { Calendly.initPopupWidget({url: 'https://calendly.com/sergei-tokmakov/30-minute-zoom-meeting?hide_gdpr_banner=1'}); } catch (error) { console.error("Error opening Calendly:", error); window.open('https://terms.law/call/', '_blank'); } }; // Render form based on current tab const renderForm = () => { switch (currentTab) { case 0: // Parties return (

Company Information

Investor Information

); case 1: // Investment Terms return (

Investment Details

Format as number with commas, no dollar sign (e.g., 100,000)
Leave blank to use the effective date
Total amount to be repaid = Investment Amount × Return Multiple
); case 2: // Repayment Terms return (

Revenue Share Structure

Percentage of revenue that will be paid to investor
Minimum payment regardless of revenue
Leave blank to default to 15 days after funding

Revenue Definition