export function commercialLandscapingCalculator(form: FormTs) {
// Property type base costs
const propertyBaseCosts: Record<string, number> = {
'office-small': 5000,
'office-large': 15000,
'retail': 8000,
'shopping-center': 25000,
'hoa': 20000,
'apartment': 12000,
'industrial': 10000,
'medical': 18000,
'school': 15000,
'hotel': 20000
};
// Service frequency multipliers (annual)
const frequencyMultipliers: Record<string, number> = {
'one-time': 1.0,
'monthly': 10,
'bi-weekly': 20,
'weekly': 40
};
// Area size tiers
const areaCosts: Record<string, number> = {
'small': 0.15, // under 10,000 sq ft
'medium': 0.12, // 10,000-50,000 sq ft
'large': 0.10, // 50,000-100,000 sq ft
'xlarge': 0.08 // 100,000+ sq ft
};
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Commercial Landscaping Estimate',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Service Location Section
const locationSection = form.addSubform('serviceLocation', { title: '📍 Property Location' });
locationSection.addRow(row => {
row.addAddress('propertyAddress', {
label: 'Property Address',
placeholder: 'Enter the commercial property address...',
showMap: true,
showDistance: true,
referenceAddress: {
formattedAddress: 'Service Center, Denver, CO',
coordinates: { lat: 39.7392, lng: -104.9903 }
},
restrictToCountries: ['US', 'CA'],
distanceUnit: 'miles',
isRequired: true
});
});
locationSection.addRow(row => {
row.addTextPanel('serviceAreaInfo', {
computedValue: () => {
const addressField = locationSection.address('propertyAddress');
const miles = addressField?.distance();
if (miles == null) return '📍 Enter address to check service coverage';
if (miles <= 25) return '📍 Within primary service area - Standard rates';
if (miles <= 50) return '📍 Extended coverage - 8% distance adjustment';
if (miles <= 75) return '📍 Regional service - 15% distance adjustment';
return '📍 Remote location - Custom quote required';
},
customStyles: { 'font-size': '0.9rem', 'color': '#0369a1', 'background': '#e0f2fe', 'padding': '10px', 'border-radius': '6px' }
});
});
// Property Details Section
const propertySection = form.addSubform('propertyDetails', { title: '🏢 Property Details' });
propertySection.addRow(row => {
row.addDropdown('propertyType', {
label: 'Property Type',
options: [
{ id: 'office-small', name: 'Small Office Building' },
{ id: 'office-large', name: 'Large Office Complex' },
{ id: 'retail', name: 'Retail Store/Strip Mall' },
{ id: 'shopping-center', name: 'Shopping Center/Mall' },
{ id: 'hoa', name: 'HOA/Community' },
{ id: 'apartment', name: 'Apartment Complex' },
{ id: 'industrial', name: 'Industrial/Warehouse' },
{ id: 'medical', name: 'Medical Facility' },
{ id: 'school', name: 'School/University' },
{ id: 'hotel', name: 'Hotel/Hospitality' }
],
defaultValue: 'office-small',
isRequired: true
}, '1fr');
row.addDropdown('areaSize', {
label: 'Landscape Area',
options: [
{ id: 'small', name: 'Small (under 10,000 sq ft)' },
{ id: 'medium', name: 'Medium (10,000-50,000 sq ft)' },
{ id: 'large', name: 'Large (50,000-100,000 sq ft)' },
{ id: 'xlarge', name: 'Extra Large (100,000+ sq ft)' }
],
defaultValue: 'medium',
isRequired: true
}, '1fr');
});
propertySection.addRow(row => {
row.addSlider('sqFootage', {
label: 'Total Landscape Area (square feet)',
min: 5000,
max: 200000,
step: 5000,
defaultValue: 25000,
showValue: true
});
});
// Service Type Section
const serviceSection = form.addSubform('serviceType', { title: '🔧 Service Type' });
serviceSection.addRow(row => {
row.addRadioButton('projectType', {
label: 'Project Type',
options: [
{ id: 'new-install', name: 'New Installation - Complete landscape design & install' },
{ id: 'renovation', name: 'Renovation - Update existing landscaping' },
{ id: 'maintenance', name: 'Maintenance Contract - Ongoing care' },
{ id: 'enhancement', name: 'Enhancement - Seasonal color, upgrades' }
],
defaultValue: 'maintenance',
orientation: 'vertical',
isRequired: true
});
});
serviceSection.addRow(row => {
row.addDropdown('frequency', {
label: 'Service Frequency',
options: [
{ id: 'one-time', name: 'One-Time Service' },
{ id: 'monthly', name: 'Monthly' },
{ id: 'bi-weekly', name: 'Bi-Weekly' },
{ id: 'weekly', name: 'Weekly' }
],
defaultValue: 'weekly',
isRequired: true,
isVisible: () => {
const type = serviceSection.radioButton('projectType')?.value();
return type === 'maintenance';
}
}, '1fr');
row.addDropdown('contractLength', {
label: 'Contract Length',
options: [
{ id: '1', name: '1 Year' },
{ id: '2', name: '2 Years (-5%)' },
{ id: '3', name: '3 Years (-10%)' }
],
defaultValue: '1',
isRequired: true,
isVisible: () => {
const type = serviceSection.radioButton('projectType')?.value();
return type === 'maintenance';
}
}, '1fr');
});
// Maintenance Services Section
const maintenanceSection = form.addSubform('maintenance', {
title: '🌿 Maintenance Services',
isVisible: () => serviceSection.radioButton('projectType')?.value() === 'maintenance'
});
maintenanceSection.addRow(row => {
row.addCheckbox('mowing', {
label: 'Lawn Mowing & Edging',
defaultValue: true
}, '1fr');
row.addCheckbox('trimming', {
label: 'Shrub & Hedge Trimming',
defaultValue: true
}, '1fr');
});
maintenanceSection.addRow(row => {
row.addCheckbox('weeding', {
label: 'Weed Control & Bed Maintenance',
defaultValue: true
}, '1fr');
row.addCheckbox('fertilization', {
label: 'Fertilization Program',
defaultValue: true
}, '1fr');
});
maintenanceSection.addRow(row => {
row.addCheckbox('irrigation', {
label: 'Irrigation Management',
defaultValue: true
}, '1fr');
row.addCheckbox('leafRemoval', {
label: 'Leaf & Debris Removal',
defaultValue: true
}, '1fr');
});
maintenanceSection.addRow(row => {
row.addCheckbox('pestControl', {
label: 'Pest & Disease Control (+$200/month)',
defaultValue: false
}, '1fr');
row.addCheckbox('mulching', {
label: 'Annual Mulch Refresh (+$0.50/sq ft)',
defaultValue: true
}, '1fr');
});
// Installation Services Section
const installSection = form.addSubform('installation', {
title: '🏗️ Installation Services',
isVisible: () => {
const type = serviceSection.radioButton('projectType')?.value();
return type === 'new-install' || type === 'renovation';
}
});
installSection.addRow(row => {
row.addCheckbox('turfInstall', {
label: 'Turf/Lawn Installation',
defaultValue: true
}, '1fr');
row.addDropdown('turfType', {
label: 'Turf Type',
options: [
{ id: 'seed', name: 'Seeding ($0.20/sq ft)' },
{ id: 'sod', name: 'Sod ($1.25/sq ft)' },
{ id: 'artificial', name: 'Artificial Turf ($10/sq ft)' }
],
defaultValue: 'sod',
isVisible: () => installSection.checkbox('turfInstall')?.value() === true
}, '1fr');
});
installSection.addRow(row => {
row.addCheckbox('plantings', {
label: 'Trees, Shrubs & Plantings',
defaultValue: true
}, '1fr');
row.addDropdown('plantingLevel', {
label: 'Planting Density',
options: [
{ id: 'minimal', name: 'Minimal - Foundation only' },
{ id: 'standard', name: 'Standard - Full beds' },
{ id: 'premium', name: 'Premium - Lush, layered' }
],
defaultValue: 'standard',
isVisible: () => installSection.checkbox('plantings')?.value() === true
}, '1fr');
});
installSection.addRow(row => {
row.addCheckbox('hardscape', {
label: 'Hardscape (walkways, patios)',
defaultValue: false
}, '1fr');
row.addCheckbox('irrigationInstall', {
label: 'Irrigation System Installation',
defaultValue: true
}, '1fr');
});
// Special Areas Section
const specialSection = form.addSubform('specialAreas', { title: '✨ Special Areas' });
specialSection.addRow(row => {
row.addCheckbox('entranceArea', {
label: 'Enhanced Entrance/Signage Area (+$3,000)',
defaultValue: true
}, '1fr');
row.addCheckbox('seasonalColor', {
label: 'Seasonal Color Program (+$500/season)',
defaultValue: false
}, '1fr');
});
specialSection.addRow(row => {
row.addCheckbox('parkingIslands', {
label: 'Parking Lot Islands (+$150/island)',
defaultValue: false
}, '1fr');
row.addInteger('islandCount', {
label: 'Number of Islands',
min: 1,
max: 50,
defaultValue: 10,
isVisible: () => specialSection.checkbox('parkingIslands')?.value() === true
}, '1fr');
});
specialSection.addRow(row => {
row.addCheckbox('commonAreas', {
label: 'Common Areas/Courtyards (+$2,500)',
defaultValue: false
}, '1fr');
row.addCheckbox('waterFeature', {
label: 'Water Feature Maintenance (+$300/month)',
defaultValue: false
}, '1fr');
});
// Additional Services Section
const addonsSection = form.addSubform('addons', { title: '➕ Additional Services' });
addonsSection.addRow(row => {
row.addCheckbox('snowRemoval', {
label: 'Snow Removal Contract',
defaultValue: false
}, '1fr');
row.addDropdown('snowLevel', {
label: 'Snow Service Level',
options: [
{ id: 'basic', name: 'Basic - Plowing only (+$500/month winter)' },
{ id: 'standard', name: 'Standard - Plow + Salt (+$800/month)' },
{ id: 'priority', name: 'Priority - 24/7 response (+$1,200/month)' }
],
defaultValue: 'standard',
isVisible: () => addonsSection.checkbox('snowRemoval')?.value() === true
}, '1fr');
});
addonsSection.addRow(row => {
row.addCheckbox('lighting', {
label: 'Landscape Lighting Maintenance (+$150/month)',
defaultValue: false
}, '1fr');
row.addCheckbox('holidayDecor', {
label: 'Holiday Decoration Service (+$2,000/year)',
defaultValue: false
}, '1fr');
});
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
// Helper to calculate distance adjustment multiplier
const getDistanceAdjustmentMultiplier = () => {
const addressField = locationSection.address('propertyAddress');
const miles = addressField?.distance();
if (miles == null || miles <= 25) return 1.0;
if (miles <= 50) return 1.08;
if (miles <= 75) return 1.15;
return 1.20 + Math.floor((miles - 75) / 25) * 0.05;
};
// Price Summary Section
const summarySection = form.addSubform('summary', { title: '💰 Cost Breakdown', isCollapsible: false });
summarySection.addRow(row => {
row.addPriceDisplay('baseCost', {
label: 'Base Service Cost',
computedValue: () => {
const projectType = serviceSection.radioButton('projectType')?.value() || 'maintenance';
const propertyType = propertySection.dropdown('propertyType')?.value() || 'office-small';
const areaSize = propertySection.dropdown('areaSize')?.value() || 'medium';
const sqft = propertySection.slider('sqFootage')?.value() || 25000;
if (projectType === 'maintenance') {
const frequency = serviceSection.dropdown('frequency')?.value() || 'weekly';
const baseRate = areaCosts[areaSize] || 0.12;
const frequencyMult = frequencyMultipliers[frequency] || 40;
return Math.round(sqft * baseRate * frequencyMult / 12); // Monthly
} else {
return propertyBaseCosts[propertyType] || 5000;
}
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('servicesCost', {
label: 'Services & Add-ons',
computedValue: () => {
const projectType = serviceSection.radioButton('projectType')?.value() || 'maintenance';
const sqft = propertySection.slider('sqFootage')?.value() || 25000;
let total = 0;
if (projectType === 'maintenance') {
if (maintenanceSection.checkbox('pestControl')?.value()) total += 200;
if (maintenanceSection.checkbox('mulching')?.value()) total += sqft * 0.50 / 12;
} else {
if (installSection.checkbox('turfInstall')?.value()) {
const turfType = installSection.dropdown('turfType')?.value() || 'sod';
const turfRates: Record<string, number> = { 'seed': 0.20, 'sod': 1.25, 'artificial': 10 };
total += sqft * 0.4 * (turfRates[turfType] || 1.25);
}
if (installSection.checkbox('plantings')?.value()) {
const level = installSection.dropdown('plantingLevel')?.value() || 'standard';
const plantCosts: Record<string, number> = { 'minimal': 3000, 'standard': 8000, 'premium': 15000 };
total += plantCosts[level] || 8000;
}
if (installSection.checkbox('hardscape')?.value()) total += 10000;
if (installSection.checkbox('irrigationInstall')?.value()) total += sqft * 0.15;
}
return Math.round(total);
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('specialCost', {
label: 'Special Areas',
computedValue: () => {
const projectType = serviceSection.radioButton('projectType')?.value() || 'maintenance';
let total = 0;
if (specialSection.checkbox('entranceArea')?.value()) {
total += projectType === 'maintenance' ? 250 : 3000;
}
if (specialSection.checkbox('seasonalColor')?.value()) {
total += projectType === 'maintenance' ? 167 : 2000;
}
if (specialSection.checkbox('parkingIslands')?.value()) {
const islands = specialSection.integer('islandCount')?.value() || 10;
total += projectType === 'maintenance' ? islands * 15 : islands * 150;
}
if (specialSection.checkbox('commonAreas')?.value()) {
total += projectType === 'maintenance' ? 200 : 2500;
}
if (specialSection.checkbox('waterFeature')?.value()) total += 300;
return Math.round(total);
},
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('addonsCost', {
label: 'Additional Services',
computedValue: () => {
let total = 0;
if (addonsSection.checkbox('snowRemoval')?.value()) {
const level = addonsSection.dropdown('snowLevel')?.value() || 'standard';
const snowCosts: Record<string, number> = { 'basic': 500, 'standard': 800, 'priority': 1200 };
total += (snowCosts[level] || 800) / 3; // Amortized monthly
}
if (addonsSection.checkbox('lighting')?.value()) total += 150;
if (addonsSection.checkbox('holidayDecor')?.value()) total += 167;
return Math.round(total);
},
variant: 'default',
prefix: '+'
}, '1fr');
});
const finalSection = form.addSubform('final', {
title: '📊 Your Estimate',
isCollapsible: false,
sticky: 'bottom'
});
finalSection.addRow(row => {
row.addPriceDisplay('monthlyTotal', {
label: 'Monthly Cost',
computedValue: () => {
const projectType = serviceSection.radioButton('projectType')?.value() || 'maintenance';
const propertyType = propertySection.dropdown('propertyType')?.value() || 'office-small';
const areaSize = propertySection.dropdown('areaSize')?.value() || 'medium';
const sqft = propertySection.slider('sqFootage')?.value() || 25000;
let total = 0;
if (projectType === 'maintenance') {
const frequency = serviceSection.dropdown('frequency')?.value() || 'weekly';
const baseRate = areaCosts[areaSize] || 0.12;
const frequencyMult = frequencyMultipliers[frequency] || 40;
total = sqft * baseRate * frequencyMult / 12;
if (maintenanceSection.checkbox('pestControl')?.value()) total += 200;
if (maintenanceSection.checkbox('mulching')?.value()) total += sqft * 0.50 / 12;
} else {
total = (propertyBaseCosts[propertyType] || 5000) / 12;
if (installSection.checkbox('turfInstall')?.value()) {
const turfType = installSection.dropdown('turfType')?.value() || 'sod';
const turfRates: Record<string, number> = { 'seed': 0.20, 'sod': 1.25, 'artificial': 10 };
total += sqft * 0.4 * (turfRates[turfType] || 1.25) / 12;
}
if (installSection.checkbox('plantings')?.value()) {
const level = installSection.dropdown('plantingLevel')?.value() || 'standard';
const plantCosts: Record<string, number> = { 'minimal': 3000, 'standard': 8000, 'premium': 15000 };
total += (plantCosts[level] || 8000) / 12;
}
if (installSection.checkbox('hardscape')?.value()) total += 10000 / 12;
if (installSection.checkbox('irrigationInstall')?.value()) total += sqft * 0.15 / 12;
}
// Special areas
if (specialSection.checkbox('entranceArea')?.value()) total += projectType === 'maintenance' ? 250 : 250;
if (specialSection.checkbox('seasonalColor')?.value()) total += 167;
if (specialSection.checkbox('parkingIslands')?.value()) {
const islands = specialSection.integer('islandCount')?.value() || 10;
total += projectType === 'maintenance' ? islands * 15 : islands * 12.5;
}
if (specialSection.checkbox('commonAreas')?.value()) total += projectType === 'maintenance' ? 200 : 208;
if (specialSection.checkbox('waterFeature')?.value()) total += 300;
// Addons
if (addonsSection.checkbox('snowRemoval')?.value()) {
const level = addonsSection.dropdown('snowLevel')?.value() || 'standard';
const snowCosts: Record<string, number> = { 'basic': 500, 'standard': 800, 'priority': 1200 };
total += (snowCosts[level] || 800) / 3;
}
if (addonsSection.checkbox('lighting')?.value()) total += 150;
if (addonsSection.checkbox('holidayDecor')?.value()) total += 167;
// Contract discount
if (projectType === 'maintenance') {
const contract = serviceSection.dropdown('contractLength')?.value() || '1';
if (contract === '2') total *= 0.95;
if (contract === '3') total *= 0.90;
}
// Apply distance adjustment
total *= getDistanceAdjustmentMultiplier();
return Math.round(total);
},
variant: 'large',
suffix: '/month'
}, '1fr');
row.addPriceDisplay('annualTotal', {
label: 'Annual Contract Value',
computedValue: () => {
const projectType = serviceSection.radioButton('projectType')?.value() || 'maintenance';
const propertyType = propertySection.dropdown('propertyType')?.value() || 'office-small';
const areaSize = propertySection.dropdown('areaSize')?.value() || 'medium';
const sqft = propertySection.slider('sqFootage')?.value() || 25000;
let monthly = 0;
if (projectType === 'maintenance') {
const frequency = serviceSection.dropdown('frequency')?.value() || 'weekly';
const baseRate = areaCosts[areaSize] || 0.12;
const frequencyMult = frequencyMultipliers[frequency] || 40;
monthly = sqft * baseRate * frequencyMult / 12;
if (maintenanceSection.checkbox('pestControl')?.value()) monthly += 200;
if (maintenanceSection.checkbox('mulching')?.value()) monthly += sqft * 0.50 / 12;
} else {
return propertyBaseCosts[propertyType] || 5000;
}
// Special areas
if (specialSection.checkbox('entranceArea')?.value()) monthly += 250;
if (specialSection.checkbox('seasonalColor')?.value()) monthly += 167;
if (specialSection.checkbox('parkingIslands')?.value()) {
const islands = specialSection.integer('islandCount')?.value() || 10;
monthly += islands * 15;
}
if (specialSection.checkbox('commonAreas')?.value()) monthly += 200;
if (specialSection.checkbox('waterFeature')?.value()) monthly += 300;
// Addons
if (addonsSection.checkbox('snowRemoval')?.value()) {
const level = addonsSection.dropdown('snowLevel')?.value() || 'standard';
const snowCosts: Record<string, number> = { 'basic': 500, 'standard': 800, 'priority': 1200 };
monthly += (snowCosts[level] || 800) / 3;
}
if (addonsSection.checkbox('lighting')?.value()) monthly += 150;
if (addonsSection.checkbox('holidayDecor')?.value()) monthly += 167;
let annual = monthly * 12;
// Contract discount
const contract = serviceSection.dropdown('contractLength')?.value() || '1';
if (contract === '2') annual *= 0.95;
if (contract === '3') annual *= 0.90;
// Apply distance adjustment
annual *= getDistanceAdjustmentMultiplier();
return Math.round(annual);
},
variant: 'success',
suffix: '/year'
}, '1fr');
});
finalSection.addRow(row => {
row.addTextPanel('disclaimer', {
computedValue: () => 'Estimates based on average commercial rates. Final pricing depends on site assessment, accessibility, and specific requirements. Volume discounts available for multi-property contracts.',
customStyles: { 'font-size': '0.85rem', 'color': '#64748b', 'font-style': 'italic' }
});
});
form.configureSubmitButton({
label: 'Request Commercial Quote'
});
}