export function heatPumpInstallationCalculator(form: FormTs) {
// Heat pump type base pricing
const heatPumpPricing: Record<string, number> = {
'air-source-basic': 4500,
'air-source-premium': 7000,
'mini-split-single': 3500,
'mini-split-multi': 8000,
'geothermal': 18000,
'dual-fuel': 9000
};
// Home size multipliers
const homeSizeMultipliers: Record<string, number> = {
'small': 0.8,
'medium': 1.0,
'large': 1.3,
'xlarge': 1.6
};
// Climate zone adjustments
const climateMultipliers: Record<string, number> = {
'mild': 0.9,
'moderate': 1.0,
'cold': 1.15,
'very-cold': 1.3
};
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Heat Pump Installation Estimate',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Service Location Section
const locationSection = form.addSubform('serviceLocation', { title: '📍 Installation Location' });
locationSection.addRow(row => {
row.addAddress('propertyAddress', {
label: 'Property Address',
placeholder: 'Enter your 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 area';
if (miles <= 25) return '📍 Within service area - No travel fee';
if (miles <= 50) return '📍 Extended area - $150 travel fee';
if (miles <= 75) return '📍 Remote area - $300 travel fee';
return '📍 Outside standard area - Please call for availability';
},
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('homeSize', {
label: 'Home Size',
options: [
{ id: 'small', name: 'Small (under 1,500 sq ft)' },
{ id: 'medium', name: 'Medium (1,500-2,500 sq ft)' },
{ id: 'large', name: 'Large (2,500-3,500 sq ft)' },
{ id: 'xlarge', name: 'Extra Large (3,500+ sq ft)' }
],
defaultValue: 'medium',
isRequired: true
}, '1fr');
row.addDropdown('stories', {
label: 'Number of Stories',
options: [
{ id: '1', name: 'Single Story' },
{ id: '2', name: 'Two Stories' },
{ id: '3', name: 'Three+ Stories' }
],
defaultValue: '2',
isRequired: true
}, '1fr');
});
propertySection.addRow(row => {
row.addDropdown('climateZone', {
label: 'Climate Zone',
options: [
{ id: 'mild', name: 'Mild (Rarely below 40°F)' },
{ id: 'moderate', name: 'Moderate (Winters 20-40°F)' },
{ id: 'cold', name: 'Cold (Winters 0-20°F)' },
{ id: 'very-cold', name: 'Very Cold (Below 0°F common)' }
],
defaultValue: 'moderate',
isRequired: true
}, '1fr');
row.addDropdown('existingSystem', {
label: 'Existing Heating System',
options: [
{ id: 'central-ac', name: 'Central AC (ductwork exists)' },
{ id: 'furnace', name: 'Furnace Only' },
{ id: 'boiler', name: 'Boiler/Radiators' },
{ id: 'baseboard', name: 'Electric Baseboard' },
{ id: 'none', name: 'No Central System' }
],
defaultValue: 'central-ac',
isRequired: true
}, '1fr');
});
// Heat Pump Selection Section
const systemSection = form.addSubform('systemConfig', { title: '🌡️ Heat Pump Selection' });
systemSection.addRow(row => {
row.addRadioButton('heatPumpType', {
label: 'Heat Pump Type',
options: [
{ id: 'air-source-basic', name: 'Air Source - Standard Efficiency (14-16 SEER)' },
{ id: 'air-source-premium', name: 'Air Source - High Efficiency (18-22 SEER)' },
{ id: 'mini-split-single', name: 'Ductless Mini-Split - Single Zone' },
{ id: 'mini-split-multi', name: 'Ductless Mini-Split - Multi Zone (2-4 zones)' },
{ id: 'geothermal', name: 'Geothermal Ground Source (Highest efficiency)' },
{ id: 'dual-fuel', name: 'Dual Fuel Hybrid (Heat pump + Gas furnace backup)' }
],
defaultValue: 'air-source-premium',
orientation: 'vertical',
isRequired: true
});
});
systemSection.addRow(row => {
row.addSlider('zones', {
label: 'Number of Zones',
min: 2,
max: 6,
step: 1,
defaultValue: 3,
showValue: true,
isVisible: () => {
const type = systemSection.radioButton('heatPumpType')?.value();
return type === 'mini-split-multi';
}
});
});
// Installation Options Section
const installSection = form.addSubform('installation', { title: '🔧 Installation Requirements' });
installSection.addRow(row => {
row.addRadioButton('ductwork', {
label: 'Ductwork Status',
options: [
{ id: 'existing-good', name: 'Existing ductwork in good condition' },
{ id: 'existing-repair', name: 'Existing ductwork needs repairs (+$800)' },
{ id: 'modification', name: 'Ductwork modification needed (+$2,000)' },
{ id: 'new-ductwork', name: 'New ductwork installation (+$5,000)' }
],
defaultValue: 'existing-good',
orientation: 'vertical',
isRequired: true,
isVisible: () => {
const type = systemSection.radioButton('heatPumpType')?.value();
return type !== 'mini-split-single' && type !== 'mini-split-multi';
}
});
});
installSection.addRow(row => {
row.addCheckbox('electricalUpgrade', {
label: 'Electrical Panel Upgrade (+$1,500)',
defaultValue: false
}, '1fr');
row.addCheckbox('thermostat', {
label: 'Smart Thermostat (+$350)',
defaultValue: true
}, '1fr');
});
// Additional Options Section
const addonsSection = form.addSubform('addons', { title: '✨ Additional Options' });
addonsSection.addRow(row => {
row.addCheckbox('extendedWarranty', {
label: 'Extended 10-Year Warranty (+$600)',
defaultValue: false
}, '1fr');
row.addCheckbox('maintenancePlan', {
label: 'Annual Maintenance Plan (+$300/year)',
defaultValue: true
}, '1fr');
});
addonsSection.addRow(row => {
row.addCheckbox('airPurifier', {
label: 'Whole-Home Air Purifier (+$800)',
defaultValue: false
}, '1fr');
row.addCheckbox('zoneControl', {
label: 'Advanced Zone Control (+$1,200)',
defaultValue: false,
isVisible: () => {
const type = systemSection.radioButton('heatPumpType')?.value();
return type === 'air-source-basic' || type === 'air-source-premium' || type === 'dual-fuel';
}
}, '1fr');
});
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
// Helper to calculate travel fee
const getTravelFee = () => {
const addressField = locationSection.address('propertyAddress');
const miles = addressField?.distance();
if (miles == null || miles <= 25) return 0;
if (miles <= 50) return 150;
if (miles <= 75) return 300;
return 450;
};
// Price Summary Section
const summarySection = form.addSubform('summary', { title: '💰 Cost Breakdown', isCollapsible: false });
summarySection.addRow(row => {
row.addPriceDisplay('equipmentCost', {
label: 'Heat Pump Equipment',
computedValue: () => {
const type = systemSection.radioButton('heatPumpType')?.value() || 'air-source-premium';
const homeSize = propertySection.dropdown('homeSize')?.value() || 'medium';
const climate = propertySection.dropdown('climateZone')?.value() || 'moderate';
const basePrice = heatPumpPricing[type] || 7000;
const sizeMultiplier = homeSizeMultipliers[homeSize] || 1.0;
const climateMultiplier = climateMultipliers[climate] || 1.0;
let cost = Math.round(basePrice * sizeMultiplier * climateMultiplier);
if (type === 'mini-split-multi') {
const zones = systemSection.slider('zones')?.value() || 3;
cost = Math.round(cost * (zones / 3));
}
return cost;
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('installationCost', {
label: 'Installation Labor',
computedValue: () => {
const type = systemSection.radioButton('heatPumpType')?.value() || 'air-source-premium';
const stories = propertySection.dropdown('stories')?.value() || '2';
let baseCost = 2500;
if (type === 'geothermal') baseCost = 8000;
if (type === 'mini-split-single') baseCost = 1500;
if (type === 'mini-split-multi') {
const zones = systemSection.slider('zones')?.value() || 3;
baseCost = 1500 + (zones - 1) * 800;
}
const storyMultiplier = stories === '1' ? 1.0 : stories === '2' ? 1.15 : 1.3;
return Math.round(baseCost * storyMultiplier);
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('ductworkCost', {
label: 'Ductwork',
computedValue: () => {
const type = systemSection.radioButton('heatPumpType')?.value();
if (type === 'mini-split-single' || type === 'mini-split-multi') return 0;
const ductwork = installSection.radioButton('ductwork')?.value() || 'existing-good';
if (ductwork === 'existing-repair') return 800;
if (ductwork === 'modification') return 2000;
if (ductwork === 'new-ductwork') return 5000;
return 0;
},
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('upgradesCost', {
label: 'Upgrades & Add-ons',
computedValue: () => {
let total = 0;
if (installSection.checkbox('electricalUpgrade')?.value()) total += 1500;
if (installSection.checkbox('thermostat')?.value()) total += 350;
if (addonsSection.checkbox('extendedWarranty')?.value()) total += 600;
if (addonsSection.checkbox('maintenancePlan')?.value()) total += 300;
if (addonsSection.checkbox('airPurifier')?.value()) total += 800;
if (addonsSection.checkbox('zoneControl')?.value()) total += 1200;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('travelFee', {
label: 'Travel Fee',
computedValue: () => getTravelFee(),
variant: 'default',
prefix: '+',
isVisible: () => getTravelFee() > 0
});
});
summarySection.addRow(row => {
row.addPriceDisplay('federalTaxCredit', {
label: 'Federal Tax Credit (30%)',
computedValue: () => {
const type = systemSection.radioButton('heatPumpType')?.value() || 'air-source-premium';
const homeSize = propertySection.dropdown('homeSize')?.value() || 'medium';
const climate = propertySection.dropdown('climateZone')?.value() || 'moderate';
const basePrice = heatPumpPricing[type] || 7000;
const sizeMultiplier = homeSizeMultipliers[homeSize] || 1.0;
const climateMultiplier = climateMultipliers[climate] || 1.0;
let equipmentCost = Math.round(basePrice * sizeMultiplier * climateMultiplier);
if (type === 'mini-split-multi') {
const zones = systemSection.slider('zones')?.value() || 3;
equipmentCost = Math.round(equipmentCost * (zones / 3));
}
const stories = propertySection.dropdown('stories')?.value() || '2';
let installCost = 2500;
if (type === 'geothermal') installCost = 8000;
if (type === 'mini-split-single') installCost = 1500;
if (type === 'mini-split-multi') {
const zones = systemSection.slider('zones')?.value() || 3;
installCost = 1500 + (zones - 1) * 800;
}
const storyMultiplier = stories === '1' ? 1.0 : stories === '2' ? 1.15 : 1.3;
installCost = Math.round(installCost * storyMultiplier);
const totalEligible = equipmentCost + installCost;
return -Math.min(Math.round(totalEligible * 0.30), 2000);
},
variant: 'success',
prefix: ''
}, '1fr');
});
const finalSection = form.addSubform('final', {
title: '🌿 Your Estimate',
isCollapsible: false,
sticky: 'bottom'
});
finalSection.addRow(row => {
row.addPriceDisplay('totalCost', {
label: 'Estimated Total Cost',
computedValue: () => {
const type = systemSection.radioButton('heatPumpType')?.value() || 'air-source-premium';
const homeSize = propertySection.dropdown('homeSize')?.value() || 'medium';
const climate = propertySection.dropdown('climateZone')?.value() || 'moderate';
const basePrice = heatPumpPricing[type] || 7000;
const sizeMultiplier = homeSizeMultipliers[homeSize] || 1.0;
const climateMultiplier = climateMultipliers[climate] || 1.0;
let equipmentCost = Math.round(basePrice * sizeMultiplier * climateMultiplier);
if (type === 'mini-split-multi') {
const zones = systemSection.slider('zones')?.value() || 3;
equipmentCost = Math.round(equipmentCost * (zones / 3));
}
const stories = propertySection.dropdown('stories')?.value() || '2';
let installCost = 2500;
if (type === 'geothermal') installCost = 8000;
if (type === 'mini-split-single') installCost = 1500;
if (type === 'mini-split-multi') {
const zones = systemSection.slider('zones')?.value() || 3;
installCost = 1500 + (zones - 1) * 800;
}
const storyMultiplier = stories === '1' ? 1.0 : stories === '2' ? 1.15 : 1.3;
installCost = Math.round(installCost * storyMultiplier);
let ductworkCost = 0;
if (type !== 'mini-split-single' && type !== 'mini-split-multi') {
const ductwork = installSection.radioButton('ductwork')?.value() || 'existing-good';
if (ductwork === 'existing-repair') ductworkCost = 800;
if (ductwork === 'modification') ductworkCost = 2000;
if (ductwork === 'new-ductwork') ductworkCost = 5000;
}
let upgrades = 0;
if (installSection.checkbox('electricalUpgrade')?.value()) upgrades += 1500;
if (installSection.checkbox('thermostat')?.value()) upgrades += 350;
if (addonsSection.checkbox('extendedWarranty')?.value()) upgrades += 600;
if (addonsSection.checkbox('maintenancePlan')?.value()) upgrades += 300;
if (addonsSection.checkbox('airPurifier')?.value()) upgrades += 800;
if (addonsSection.checkbox('zoneControl')?.value()) upgrades += 1200;
const travelFee = getTravelFee();
return equipmentCost + installCost + ductworkCost + upgrades + travelFee;
},
variant: 'large'
}, '1fr');
row.addPriceDisplay('estimatedSavings', {
label: 'Estimated Annual Savings',
computedValue: () => {
const type = systemSection.radioButton('heatPumpType')?.value() || 'air-source-premium';
const homeSize = propertySection.dropdown('homeSize')?.value() || 'medium';
const baseSavings = 1200;
const sizeMultiplier = homeSizeMultipliers[homeSize] || 1.0;
let efficiencyBonus = 1.0;
if (type === 'air-source-premium') efficiencyBonus = 1.2;
if (type === 'geothermal') efficiencyBonus = 1.5;
return Math.round(baseSavings * sizeMultiplier * efficiencyBonus);
},
variant: 'success',
suffix: '/year'
}, '1fr');
});
finalSection.addRow(row => {
row.addTextPanel('disclaimer', {
computedValue: () => 'Estimates based on average costs. Final price depends on site assessment. Federal tax credit up to $2,000 for qualifying systems. Additional rebates may be available.',
customStyles: { 'font-size': '0.85rem', 'color': '#64748b', 'font-style': 'italic' }
});
});
form.configureSubmitButton({
label: 'Get Free Quote'
});
}