@elite-dangerous-almanac/core 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{shieldMetrics}from"./chunk-2FHHMYDC.js";import{getShipBySymbol,getShipByName}from"./chunk-WNGQ3IAM.js";import{parseSlef,toSlef,stringifySlef,getLoadoutModifier}from"./chunk-UXFMVZAY.js";import{sourcePurchaseFromLoadout,getSourceModuleValue}from"./chunk-IYU4WLFM.js";import{weaponsCapacitorMetrics}from"./chunk-FMPRCYKY.js";import{powerBudget}from"./chunk-BMM6GQAU.js";import{isCargoHatchSlot,matchingKeyIn,ownKeyIn,isBuiltInHullModule,isNonOutfittingSlot,cloneLoadoutModule,identifyPreEngineeredVariant,cloneModuleStats,availableBlueprintsFor,availableExperimentalsFor,blueprintAvailableFor,blueprintRoutesFor,experimentalAvailableFor,primitiveEngineeringInputsFor,missingBaseLabels,journalModifiersFor,getPreEngineeredStats,getPreEngineeredJournalModifiers,getPreEngineeredModifiers,ordinaryEngineeringProof,unresolvedModifiers,orderBySlotLayout,FITTED_ITEM,isFinalGuardianWeaponEngineering,scaleDamageComponents}from"./chunk-Q4E2V6RE.js";import{weaponMetrics,sumWeaponMetrics,combinedRateOfFire}from"./chunk-LJI7VXJD.js";import{builtInModuleBySymbol,getBulkheadsForShip}from"./chunk-R26GVRMI.js";import{getPreEngineeredVariants}from"./chunk-EU42PAV4.js";import{shieldRecovery,cellBankSummary}from"./chunk-VZZUNSDF.js";import{completeResult,calculateUnladenMass,calculateCargoCapacity,calculateFuelCapacity,incompleteResult}from"./chunk-GOMBLS2T.js";import{validateLoadout,fixedSlotReason}from"./chunk-VKN65H2U.js";import{mobilityMetrics}from"./chunk-24INI4U7.js";import{calculateModuleLimits}from"./chunk-KPETDYQX.js";import{ALL_MODULES}from"./chunk-PNZCLQDJ.js";import{CORE_MODULES}from"./chunk-O72KI7RP.js";import{getExperimentalEffect}from"./chunk-PHPLZEFS.js";import{heatMetrics}from"./chunk-YU5GND2Q.js";import{singleJumpRange,frameShiftDriveMassFactor,fuelPerJump,totalRange}from"./chunk-GQ5GX5TB.js";import{ammunitionCapacity}from"./chunk-AA3K5XUE.js";import{armourMetrics}from"./chunk-FGXWVFN6.js";import{baseStats,computeModifiers,labelsForDamageType,scaleForLabel,fieldForLabel,labelsForField,capabilityValueForLabel,damageTypeForLabel}from"./chunk-SVZARHWP.js";import{resolveBlueprintForModule}from"./chunk-W5G2NUCZ.js";import{getExperimentalsForModule}from"./chunk-QTZPA2FR.js";import{getBlueprintGrade}from"./chunk-QI22FKBG.js";import{getDefaultLoadout}from"./chunk-GRIK3EDH.js";import{distributorMetrics}from"./chunk-P2QOL63K.js";import{loadoutSlotName}from"./chunk-KAA4VOOB.js";import{parseSlotName,enumerateSlots,SLOT_RESTRICTION_LABELS}from"./chunk-RAO35XDF.js";import{normalizeKey}from"./chunk-BKWLI44T.js";import{truncate,describeValue,requireString,requireStringIfPresent}from"./chunk-PKWVG2JY.js";import{deepFreeze}from"./chunk-DURKO7JU.js";var PREFIX={powerPlant:["int_powerplant","int_guardianpowerplant"],thrusters:["int_engine","int_mkiiagileboost_engine"],frameShiftDrive:["int_hyperdrive"],powerDistributor:["int_powerdistributor","int_guardianpowerdistributor"],shieldGenerator:["int_shieldgenerator"],shieldCellBank:["int_shieldcellbank"],shieldBooster:["hpt_shieldbooster"],shieldReinforcement:["int_guardianshieldreinforcement"],hullReinforcement:["int_hullreinforcement","int_guardianhullreinforcement","int_metaalloyhullreinforcement"],moduleReinforcement:["int_modulereinforcement","int_guardianmodulereinforcement"]};var startsWithAny=(symbol,prefixes)=>prefixes.some(prefix=>symbol.toLowerCase().startsWith(prefix));function isPowerDistributor(module,stats){return stats?.slot?stats.slot==="powerDistributor":startsWithAny(module.Item,PREFIX.powerDistributor)}function isPowerPlant(module,stats){const parsed=parseSlotName(module.Slot);if(parsed?.kind==="core"&&parsed.core==="powerPlant")return true;return stats?.slot?stats.slot==="powerPlant":startsWithAny(module.Item,PREFIX.powerPlant)}function isThruster(module,stats){const parsed=parseSlotName(module.Slot);if(parsed?.kind==="core"&&parsed.core==="thrusters")return true;return stats?.slot?stats.slot==="thrusters":startsWithAny(module.Item,PREFIX.thrusters)}function isFrameShiftDrive(module,stats){const parsed=parseSlotName(module.Slot);if(parsed?.kind==="core"&&parsed.core==="frameShiftDrive")return true;return stats?.slot?stats.slot==="frameShiftDrive":startsWithAny(module.Item,PREFIX.frameShiftDrive)}function isEnabled(module){return module.On!==false}function priorityOf(module){return(module.Priority??0)+1}function effectiveStat(module,field,stats){const stated=statedModifier(module,field);if(stated!==void 0)return stated;const base=stats?.[field];return typeof base==="number"?base:void 0}function statedModifier(module,field){for(const label of labelsForField(field)){if(capabilityValueForLabel(label)!==null)continue;const modified=getLoadoutModifier(module,label);if(modified!==null)return modified/scaleForLabel(label)}return void 0}function effectiveCapability(module,field,stats){for(const label of labelsForField(field)){if(capabilityValueForLabel(label)===null)continue;if(module.Engineering?.Modifiers?.some(modifier=>modifier.Label.toLowerCase()===label.toLowerCase())){return true}}const base=stats[field];return typeof base==="boolean"?base:void 0}function effectiveDamageDistribution(module,stats){const fromEffect=module.Engineering?.ExperimentalEffect?getExperimentalEffect(module.Engineering.ExperimentalEffect)?.damageDistribution:void 0;const distribution={...fromEffect??stats.damageDistribution};let resolved=fromEffect!==void 0||stats.damageDistribution!==void 0;const seen=/* @__PURE__ */new Set;for(const modifier of module.Engineering?.Modifiers??[]){const type=damageTypeForLabel(modifier.Label);if(type===null||seen.has(type))continue;seen.add(type);if(modifier.Value===void 0)continue;distribution[type]=modifier.Value/scaleForLabel(modifier.Label);resolved=true}return resolved?distribution:void 0}function convertsDamage(module){if(module.Engineering?.ExperimentalEffect&&getExperimentalEffect(module.Engineering.ExperimentalEffect)?.damageDistribution){return true}return(module.Engineering?.Modifiers??[]).some(modifier=>damageTypeForLabel(modifier.Label)!==null)}function modifierRatio(module,stats,field){const base=stats?.[field];if(typeof base!=="number"||base===0)return 1;const effective=effectiveStat(module,field,stats);return effective===void 0?1:effective/base}function relatedStat(module,stats,field,ratio){const stated=statedModifier(module,field);if(stated!==void 0)return stated;const base=stats?.[field];return typeof base==="number"?base*ratio:void 0}function effectiveModule(module,stats){if(!stats||!module.Engineering)return stats;const merged={...stats};const fields=new Set(Object.keys(stats));for(const modifier of module.Engineering.Modifiers??[]){const field=fieldForLabel(modifier.Label,stats);if(field)fields.add(field)}for(const key of fields){const capability=effectiveCapability(module,key,stats);if(capability!==void 0){merged[key]=capability;continue}const value=effectiveStat(module,key,stats);if(value!==void 0)merged[key]=value}if(stats.engineeringGroup==="thrusters"){const massRatio=modifierRatio(module,stats,"optMass");const minMass=relatedStat(module,stats,"minMass",massRatio);const maxMass=relatedStat(module,stats,"maxMass",massRatio);if(minMass!==void 0)merged.minMass=minMass;if(maxMass!==void 0)merged.maxMass=maxMass}if(stats.engineeringGroup==="thrusters"||stats.engineeringGroup==="shieldGenerators"){const performanceRatio=modifierRatio(module,stats,"optMultiplier");const minMultiplier=relatedStat(module,stats,"minMultiplier",performanceRatio);const maxMultiplier=relatedStat(module,stats,"maxMultiplier",performanceRatio);if(minMultiplier!==void 0)merged.minMultiplier=minMultiplier;if(maxMultiplier!==void 0)merged.maxMultiplier=maxMultiplier;if(stats.engineeringGroup==="thrusters"){for(const field of["minSpeedMultiplier","optSpeedMultiplier","maxSpeedMultiplier","minRotationMultiplier","optRotationMultiplier","maxRotationMultiplier"]){const value=stats[field];if(value!==void 0)merged[field]=value*performanceRatio}}}const damageDistribution=effectiveDamageDistribution(module,stats);if(damageDistribution)merged.damageDistribution=damageDistribution;if(stats.category==="hardpoint")normalizeEffectiveWeapon(module,merged);if(convertsDamage(module)){delete merged.damageComponents}else if(stats.damageComponents){merged.damageComponents=scaleDamageComponents(stats.damageComponents,stats.damage,typeof merged.damage==="number"?merged.damage:void 0)}return merged}function powerConsumerFor(module,stats){const draw=effectiveStat(module,"powerDraw",stats);const parsedSlot=parseSlotName(module.Slot);const mounted=stats?.category==="hardpoint"||stats?.category==="utility";const deployedOnly=stats!==null?mounted&&stats.alwaysPowered!==true:parsedSlot?.kind==="hardpoint"?true:parsedSlot?.kind==="utility"?null:false;const common={priority:priorityOf(module),enabled:isEnabled(module),deployedOnly:deployedOnly,label:module.Slot,symbol:module.Item};if(draw===void 0){const inherentlyPassiveSlot=parsedSlot?.kind==="armour"||parsedSlot?.kind==="core"&&(parsedSlot.core==="powerPlant"||parsedSlot.core==="fuelTank");if(stats!==null||inherentlyPassiveSlot||isNonOutfittingSlot(module.Slot))return null;return{drawUnknown:true,...common}}if(draw===0)return null;return{draw:draw,...common}}function powerAvailable(modules,statsFor){for(const module of modules){const stats=statsFor(module);if(!isPowerPlant(module,stats))continue;if(!isEnabled(module))return 0;return effectiveStat(module,"powerCapacity",stats)??0}return 0}function metricIssue(field,reason,module){const defaultSlot=field==="powerCapacity"?"PowerPlant":field==="thrusters"?"MainEngines":void 0;const slot=module?.Slot??defaultSlot;const symbol=module?.Item;const params={field:field,reason:reason,...slot===void 0?{}:{slot:slot},...symbol===void 0?{}:{symbol:symbol}};let message;if(reason==="missing"){message=field==="powerCapacity"?"PowerPlant: no power plant is fitted":field==="thrusters"?"MainEngines: no thrusters are fitted":"no shield generator is fitted"}else if(reason==="unresolved"){const unavailable=field==="thrusters"?"thruster stats":field==="shieldGenerator"?"shield-generator stats":field==="powerCapacity"?"power capacity":field;message=`${truncate(slot??field)}: ${unavailable} unavailable for ${truncate(symbol??field)}`}else if(reason==="disabled"){message=`${truncate(slot??field)}: ${truncate(symbol??field)} is switched off`}else if(reason==="invalid"){message=`${truncate(slot??field)}: ${truncate(symbol??field)} has invalid ${field}`}else{message=`${truncate(slot??field)}: ${truncate(symbol??field)} is not powered with hardpoints retracted`}return{field:field,reason:reason,...slot===void 0?{}:{slot:slot},...symbol===void 0?{}:{symbol:symbol},message:message,params:params}}function powerPlantIssueFor(modules,statsFor){for(const module of modules){const stats=statsFor(module);if(!isPowerPlant(module,stats))continue;if(!isEnabled(module))return metricIssue("powerCapacity","disabled",module);const capacity=effectiveStat(module,"powerCapacity",stats);if(capacity===void 0)return metricIssue("powerCapacity","unresolved",module);return!Number.isFinite(capacity)||capacity<=0?metricIssue("powerCapacity","invalid",module):null}return metricIssue("powerCapacity","missing")}function powerDrawIssueFor(modules,statsFor){for(const module of modules){const consumer=powerConsumerFor(module,statsFor(module));if(consumer&&!consumer.drawUnknown&&(consumer.draw===void 0||!Number.isFinite(consumer.draw)||consumer.draw<0)){return metricIssue("powerDraw","invalid",module)}}return null}function poweredMetricBudgetFor(field,module,stats,modules,getBudget,statsFor){if(!isEnabled(module))return incompleteResult([metricIssue(field,"disabled",module)]);const plantIssue=powerPlantIssueFor(modules,statsFor);if(plantIssue)return incompleteResult([plantIssue]);const drawIssue=powerDrawIssueFor(modules,statsFor);if(drawIssue)return incompleteResult([drawIssue]);const budget=getBudget();return budget.available>0&&poweredStates(module,stats,budget).retracted?completeResult(budget):incompleteResult([metricIssue(field,"shed",module)])}function poweredShieldGeneratorResultFor(modules,getBudget,statsFor){for(const module of modules){if(!startsWithAny(module.Item,PREFIX.shieldGenerator))continue;const stats=statsFor(module);const powered=poweredMetricBudgetFor("shieldGenerator",module,stats,modules,getBudget,statsFor);if(!powered.complete)return powered;return stats===null?incompleteResult([metricIssue("shieldGenerator","unresolved",module)]):completeResult({module:module,budget:powered.value})}return incompleteResult([metricIssue("shieldGenerator","missing")])}function mapResistanceFields(read){return{kineticResistance:read("kineticResistance")??0,thermalResistance:read("thermalResistance")??0,explosiveResistance:read("explosiveResistance")??0,causticResistance:read("causticResistance")??0}}function resistancesOf(module,stats){return mapResistanceFields(field=>effectiveStat(module,field,stats))}function shieldInputFor(ship,modules,budget,systemsPips,statsFor){let generator=null;const boosters=[];let reinforcement=0;for(const module of modules){if(!isEnabled(module))continue;const stats=statsFor(module);if(!(budget.available>0&&poweredStates(module,stats,budget).retracted))continue;if(!generator&&startsWithAny(module.Item,PREFIX.shieldGenerator)){const massRatio=modifierRatio(module,stats,"optMass");const strengthRatio=modifierRatio(module,stats,"optMultiplier");const optMass=effectiveStat(module,"optMass",stats);const minMass=relatedStat(module,stats,"minMass",massRatio);const maxMass=relatedStat(module,stats,"maxMass",Math.max(1,massRatio));const optMultiplier=effectiveStat(module,"optMultiplier",stats);const minMultiplier=relatedStat(module,stats,"minMultiplier",strengthRatio);const maxMultiplier=relatedStat(module,stats,"maxMultiplier",strengthRatio);generator={...optMass===void 0?{}:{optMass:optMass},...minMass===void 0?{}:{minMass:minMass},...maxMass===void 0?{}:{maxMass:maxMass},...optMultiplier===void 0?{}:{optMultiplier:optMultiplier},...minMultiplier===void 0?{}:{minMultiplier:minMultiplier},...maxMultiplier===void 0?{}:{maxMultiplier:maxMultiplier},...resistancesOf(module,stats)}}else if(startsWithAny(module.Item,PREFIX.shieldBooster)){boosters.push({shieldBoost:effectiveStat(module,"shieldBoost",stats)??0,...resistancesOf(module,stats)})}else if(startsWithAny(module.Item,PREFIX.shieldReinforcement)){reinforcement+=effectiveStat(module,"shieldAddition",stats)??0}}return{hullMass:ship.hullMass,baseShieldStrength:ship.baseShieldStrength,generator:generator,boosters:boosters,reinforcement:reinforcement,systemsPips:systemsPips}}function shieldInputResultFor(ship,modules,getBudget,systemsPips,statsFor){const fitted=poweredShieldGeneratorResultFor(modules,getBudget,statsFor);if(!fitted.complete)return fitted;const input=shieldInputFor(ship,modules,fitted.value.budget,systemsPips,statsFor);return completeResult(input)}function mobilityInputResultFor(ship,modules,getBudget,mass,enginesPips,statsFor){let thrusters=null;for(const module of modules){const stats=statsFor(module);if(!isThruster(module,stats))continue;const powered=poweredMetricBudgetFor("thrusters",module,stats,modules,getBudget,statsFor);if(!powered.complete)return powered;const effective=effectiveModule(module,stats);const minMass=effective?.minMass;const optMass=effective?.optMass;const maxMass=effective?.maxMass;const minMultiplier=effective?.minMultiplier;const optMultiplier=effective?.optMultiplier;const maxMultiplier=effective?.maxMultiplier;if(minMass===void 0||optMass===void 0||maxMass===void 0||minMultiplier===void 0||optMultiplier===void 0||maxMultiplier===void 0){return incompleteResult([metricIssue("thrusters","unresolved",module)])}thrusters={minMass:minMass,optMass:optMass,maxMass:maxMass,minMultiplier:minMultiplier,optMultiplier:optMultiplier,maxMultiplier:maxMultiplier,...effective?.optSpeedMultiplier===void 0?{}:{speedCurve:{minMass:minMass,optMass:optMass,maxMass:maxMass,minMultiplier:effective.minSpeedMultiplier??minMultiplier,optMultiplier:effective.optSpeedMultiplier,maxMultiplier:effective.maxSpeedMultiplier??maxMultiplier}},...effective?.optRotationMultiplier===void 0?{}:{rotationCurve:{minMass:minMass,optMass:optMass,maxMass:maxMass,minMultiplier:effective.minRotationMultiplier??minMultiplier,optMultiplier:effective.optRotationMultiplier,maxMultiplier:effective.maxRotationMultiplier??maxMultiplier}}};break}if(!thrusters)return incompleteResult([metricIssue("thrusters","missing")]);return completeResult({minimumSpeed:ship.minimumSpeed,maximumSpeed:ship.maximumSpeed,boost:ship.boost,minPitch:ship.minPitch,pitch:ship.pitch,minRoll:ship.minRoll,roll:ship.roll,minYaw:ship.minYaw,yaw:ship.yaw,mass:typeof mass==="function"?mass():mass,thrusters:thrusters,enginesPips:enginesPips})}function shieldRecoveryInputResultFor(ship,modules,getBudget,systemsPips,statsFor){const generator=poweredShieldGeneratorResultFor(modules,getBudget,statsFor);if(!generator.complete)return generator;const{module:generatorModule,budget:budget}=generator.value;let distributor=null;for(const module of modules){const stats=statsFor(module);if(isPowerDistributor(module,stats)&&isEnabled(module)&&budget.available>0&&poweredStates(module,stats,budget).retracted)distributor=module}const generatorStats=statsFor(generatorModule);const distributorStats=distributor?statsFor(distributor):null;const strength=shieldMetrics(shieldInputFor(ship,modules,budget,0,statsFor)).strength;return completeResult({strength:strength,regenRate:effectiveStat(generatorModule,"shieldRegenRate",generatorStats)??0,brokenRegenRate:effectiveStat(generatorModule,"shieldBrokenRegenRate",generatorStats)??0,distributorDraw:effectiveStat(generatorModule,"distributorDraw",generatorStats)??.6,systemsCapacity:distributor?effectiveStat(distributor,"systemsCapacity",distributorStats)??0:0,systemsRecharge:distributor?effectiveStat(distributor,"systemsRecharge",distributorStats)??0:0,systemsPips:systemsPips})}function weaponsCapacitorInputFor(modules,weaponsPips,budget,statsFor){let weaponsCapacity=0;let weaponsRecharge=0;let sustainedEnergyPerSecond=0;for(const module of modules){if(!isEnabled(module))continue;const stats=statsFor(module);if(!poweredStates(module,stats,budget).deployed)continue;if(isPowerDistributor(module,stats)){weaponsCapacity=effectiveStat(module,"weaponsCapacity",stats)??0;weaponsRecharge=effectiveStat(module,"weaponsRecharge",stats)??0}const weapon=weaponStatsFor(module,stats);if(weapon){sustainedEnergyPerSecond+=weaponMetrics(weapon).sustainedEnergyPerSecond}}return{weaponsCapacity:weaponsCapacity,weaponsRecharge:weaponsRecharge,sustainedEnergyPerSecond:sustainedEnergyPerSecond,weaponsPips:weaponsPips}}function distributorInputFor(modules,pips,budget,statsFor){for(const module of modules){if(!isEnabled(module))continue;const stats=statsFor(module);if(!isPowerDistributor(module,stats))continue;if(!poweredStates(module,stats,budget).retracted)return null;const systemsCapacity=effectiveStat(module,"systemsCapacity",stats);const systemsRecharge=effectiveStat(module,"systemsRecharge",stats);const enginesCapacity=effectiveStat(module,"enginesCapacity",stats);const enginesRecharge=effectiveStat(module,"enginesRecharge",stats);const weaponsCapacity=effectiveStat(module,"weaponsCapacity",stats);const weaponsRecharge=effectiveStat(module,"weaponsRecharge",stats);if(systemsCapacity===void 0||systemsRecharge===void 0||enginesCapacity===void 0||enginesRecharge===void 0||weaponsCapacity===void 0||weaponsRecharge===void 0){return null}return{systemsCapacity:systemsCapacity,systemsRecharge:systemsRecharge,enginesCapacity:enginesCapacity,enginesRecharge:enginesRecharge,weaponsCapacity:weaponsCapacity,weaponsRecharge:weaponsRecharge,...pips}}return null}function heatInputFor(ship,modules,budget,statsFor){let heatEfficiency;let thrusterHeatRate=0;let deployedThrusterHeatRate=0;let fsdHeatRate=0;let weaponsCapacity=0;const weapons=[];const unknownWeaponHeat=[];for(const module of modules){const stats=statsFor(module);if(isPowerPlant(module,stats)){if(!isEnabled(module))return null;heatEfficiency=effectiveStat(module,"heatEfficiency",stats);continue}if(!isEnabled(module))continue;const running=poweredStates(module,stats,budget);if(isThruster(module,stats)){const heat=effectiveStat(module,"engineHeatRate",stats)??0;if(running.retracted)thrusterHeatRate+=heat;if(running.deployed)deployedThrusterHeatRate+=heat}else if(isFrameShiftDrive(module,stats)){if(running.retracted)fsdHeatRate+=effectiveStat(module,"fsdHeatRate",stats)??0}else if(isPowerDistributor(module,stats)){if(running.deployed){weaponsCapacity=effectiveStat(module,"weaponsCapacity",stats)??0}}const weapon=weaponStatsFor(module,stats);if(!running.deployed)continue;if(!weapon){if(stats===null&&parseSlotName(module.Slot)?.kind==="hardpoint"){unknownWeaponHeat.push(module.Slot)}continue}weapons.push({heatPerSecond:weaponMetrics(weapon).sustainedHeatPerSecond,distributorDraw:weapon.distributorDraw??0})}if(heatEfficiency===void 0)return null;return{heatCapacity:ship.heatCapacity,heatDissipation:ship.heatDissipation,heatEfficiency:heatEfficiency,retractedPowerDraw:poweredDraw(budget,"retracted"),deployedPowerDraw:poweredDraw(budget,"deployed"),thrusterHeatRate:thrusterHeatRate,deployedThrusterHeatRate:deployedThrusterHeatRate,fsdHeatRate:fsdHeatRate,weaponsCapacity:weaponsCapacity,weapons:weapons,unknownDraws:budget.unknownDraws.map(consumer=>consumer.label??"(unnamed module)"),unknownWeaponHeat:unknownWeaponHeat}}function poweredDraw(budget,state){const powered=state==="retracted"?"poweredRetracted":"poweredDeployed";return budget.bands.reduce((total,band)=>band[powered]?total+band[state]:total,0)}function poweredStates(module,stats,budget){const draw=effectiveStat(module,"powerDraw",stats);if(draw===void 0||draw===0)return{retracted:true,deployed:true};const band=budget.bands[Math.min(budget.bands.length,Math.max(1,priorityOf(module)))-1];if(!band)return{retracted:true,deployed:true};return{retracted:band.poweredRetracted,deployed:band.poweredDeployed}}function cellBankInputsFor(modules,budget,statsFor){const banks=[];for(const module of modules){if(!startsWithAny(module.Item,PREFIX.shieldCellBank))continue;const stats=statsFor(module);const effective=effectiveModule(module,stats);const ammunition=effective?ammunitionCapacity(effective):null;banks.push({slot:module.Slot,symbol:module.Item,reinforcementRate:effective?.shieldBankReinforcement??0,cells:ammunition?.total??0,spinUp:effective?.shieldBankSpinUp??0,duration:effective?.shieldBankDuration??0,heat:effective?.shieldBankHeat??0,powered:budget.available>0&&isEnabled(module)&&poweredStates(module,stats,budget).deployed})}return banks}function stockBulkhead(ship){const variants=getBulkheadsForShip(ship.name,CORE_MODULES);return variants.find(v=>v.symbol.toLowerCase().endsWith("_default"))??variants.find(v=>v.mass===0)??variants[0]??null}function armourInputFor(ship,modules,statsFor){const reinforcements=[];const moduleReinforcements=[];let bulkhead=null;for(const module of modules){if(!isEnabled(module))continue;const stats=statsFor(module);if(module.Slot.toLowerCase()==="armour"){bulkhead={hullBoost:effectiveStat(module,"hullBoost",stats)??0,...resistancesOf(module,stats)}}else if(startsWithAny(module.Item,PREFIX.hullReinforcement)){const boost=getLoadoutModifier(module,"DefenceModifierHealthMultiplier");reinforcements.push({hullReinforcement:effectiveStat(module,"hullReinforcement",stats)??0,hullBoost:boost===null?0:boost/scaleForLabel("DefenceModifierHealthMultiplier"),...resistancesOf(module,stats)})}else if(startsWithAny(module.Item,PREFIX.moduleReinforcement)){moduleReinforcements.push({moduleProtection:effectiveStat(module,"moduleProtection",stats)??0,integrity:effectiveStat(module,"integrity",stats)??0})}}if(!bulkhead){const stock=stockBulkhead(ship);bulkhead=stock?{hullBoost:stock.hullBoost??0,...mapResistanceFields(field=>stock[field])}:null}return{baseArmour:ship.baseArmour,bulkhead:bulkhead,reinforcements:reinforcements,moduleReinforcements:moduleReinforcements}}var WEAPON_FIELDS=["damage","roundsPerShot","rateOfFire","burstInterval","burstRounds","burstRateOfFire","chargeTime","clipSize","ammoMaximum","reloadTime","distributorDraw","thermalLoad","powerDraw","maximumRange","falloffRange","armourPiercing"];function weaponStatsFor(module,stats){if(!stats||stats.category!=="hardpoint")return null;const weapon={};for(const field of WEAPON_FIELDS){const value=effectiveStat(module,field,stats);if(value!==void 0)weapon[field]=value}normalizeEffectiveWeapon(module,weapon);const damageDistribution=effectiveDamageDistribution(module,stats);if(damageDistribution)weapon.damageDistribution=damageDistribution;if(stats.damageComponents&&!convertsDamage(module)){weapon.damageComponents=scaleDamageComponents(stats.damageComponents,stats.damage,typeof weapon.damage==="number"?weapon.damage:void 0)}if(stats.projectileRange)weapon.projectileRange={...stats.projectileRange};return weapon}function burstAdjustedRateOfFire(module,weapon){if(getLoadoutModifier(module,"RateOfFire")!==null)return void 0;const touched=["BurstSize","BurstRateOfFire","BurstInterval"].some(label=>getLoadoutModifier(module,label)!==null);if(!touched)return void 0;return combinedRateOfFire(weapon)}function normalizeEffectiveWeapon(module,weapon){const rate=burstAdjustedRateOfFire(module,weapon);if(rate!==void 0)weapon.rateOfFire=rate;const statedDamagePerSecond=getLoadoutModifier(module,"DamagePerSecond");const firingFactor=Number(weapon.roundsPerShot??1)*Number(weapon.rateOfFire??1);if(statedDamagePerSecond!==null&&firingFactor>0){weapon.damage=statedDamagePerSecond/firingFactor}const{maximumRange:maximumRange,falloffRange:falloffRange}=weapon;if(maximumRange!==void 0&&falloffRange!==void 0&&falloffRange>maximumRange){weapon.falloffRange=maximumRange}}var MILITARY_PREFIXES=["int_hullreinforcement","int_metaalloyhullreinforcement","int_modulereinforcement","int_shieldcellbank","int_guardianhullreinforcement","int_guardianmodulereinforcement","int_guardianshieldreinforcement"];var MINING_PREFIXES=["hpt_mininglaser","hpt_mining_abrblstr","hpt_mining_seismchrgwarhd","hpt_mining_subsurfdispmisle","hpt_human_extraction","hpt_miningtoolv2"];var CARGO_PREFIXES=["int_cargorack","int_largecargorack","int_corrosionproofcargorack","int_fueltank"];var RESTRICTED_SLOT_PREFIXES={mining:MINING_PREFIXES,military:MILITARY_PREFIXES,cargo:CARGO_PREFIXES,limpetController:["int_dronecontrol","int_multidronecontrol"],vesselHangar:["int_fighterbay"],passenger:["int_passengercabin","int_mkii_passengercabin"],planetaryApproachSuite:["int_planetapproachsuite"]};var problem=(constraint,message,params)=>({constraint:constraint,message:message,...params===void 0?{}:{params:params}});function restrictionProblem(slot,symbol){const restriction=slot.restriction;if(!restriction)return null;if(RESTRICTED_SLOT_PREFIXES[restriction].some(prefix=>symbol.startsWith(prefix))){return null}return problem("restrictedMount",`slot only takes ${SLOT_RESTRICTION_LABELS[restriction]}`,{restriction:restriction})}function moduleSlotProblem(slot,module){const required=module.restrictedToSlot;if(!required||slot.restriction===required)return null;return problem("restrictedMount",`module only fits a mount that takes ${SLOT_RESTRICTION_LABELS[required]}`,{restriction:required})}function moduleFitProblem(shipSymbol,slot,module){if(slot.kind==="cargoHatch"){return problem("immutableSlot","the cargoHatch slot cannot be changed")}if(slot.kind==="armour"){const hull=getShipBySymbol(shipSymbol);if(module.slot!=="armour"||module.ship===void 0){return problem("armourRequired","not a ship armour module")}if(!hull||module.ship.toLowerCase()!==hull.name.toLowerCase()){const armourHull=getShipByName(module.ship);return problem("wrongHullArmour",`armour belongs to ${truncate(module.ship)}, not ${truncate(hull?.name??shipSymbol)}`,{armourShipName:module.ship,...armourHull===null?{}:{armourShipSymbol:armourHull.symbol},shipSymbol:shipSymbol,...hull===null?{}:{shipName:hull.name}})}return null}const restricted=module.restrictedToShips;if(restricted&&!restricted.some(symbol2=>symbol2.toLowerCase()===shipSymbol.toLowerCase())){const allowedShipNames=restricted.map(symbol2=>{const hull=getShipBySymbol(symbol2);return hull?.name??symbol2});const labels=restricted.map((symbol2,index)=>{const name=allowedShipNames[index];return name===symbol2?symbol2:`${name} (${symbol2})`});return problem("restrictedHull",`module is restricted to ${truncate(labels.join(", "))}`,{allowedShipNames:allowedShipNames,allowedShipSymbols:[...restricted],shipSymbol:shipSymbol})}const wrongMount=moduleSlotProblem(slot,module);if(wrongMount)return wrongMount;const symbol=module.symbol.toLowerCase();const moduleSlot=module.slot;switch(slot.kind){case"core":if(moduleSlot!==slot.core){return problem("wrongCoreType",`not a ${slot.core} module`,{requiredCore:slot.core,moduleSlot:moduleSlot??"none"})}break;case"hardpoint":{if(module.category!=="hardpoint"){return problem("hardpointRequired","not a hardpoint weapon")}const restricted2=restrictionProblem(slot,symbol);if(restricted2)return restricted2;break}case"utility":if(module.category!=="utility"){return problem("utilityRequired","not a utility module")}return null;case"optional":{const isFuelTank=moduleSlot==="fuelTank";if(module.category!=="internal"&&!isFuelTank){return problem("optionalInternalRequired","not an optional-internal module")}if(moduleSlot&&!isFuelTank){return problem("coreModuleInOptionalSlot","a core module only fits its core slot")}const restricted2=restrictionProblem(slot,symbol);if(restricted2)return restricted2;break}}return module.class>slot.size?problem("oversized",`module size ${truncate(module.class)} exceeds slot size ${slot.size}`,{moduleClass:module.class,slotSize:slot.size}):null}function moduleFitError(shipSymbol,slot,module){return moduleFitProblem(shipSymbol,slot,module)?.message??null}var REBUY_FRACTION=.05;function exportLoadoutEvent(input,options){const fromSource=options.credits==="source";const source=fromSource?input.sourcePurchase:null;const totals=source!==null&&sourceTotalsHold(input.modules,source)?source:null;const hullValue=fromSource?source?.hullValue??null:input.retailHullValue;const modulesValue=fromSource?totals?.modulesValue??null:computedModulesValue(input.modules,input.statsFor);const rebuy=fromSource?totals?.rebuy??null:hullValue===null||modulesValue===null?null:Math.trunc((hullValue+modulesValue)*REBUY_FRACTION);return{event:"Loadout",Ship:input.shipSymbol.toLowerCase(),...input.shipName===void 0?{}:{ShipName:input.shipName},...input.shipIdent===void 0?{}:{ShipIdent:input.shipIdent},...hullValue===null?{}:{HullValue:hullValue},...modulesValue===null?{}:{ModulesValue:modulesValue},...input.unladenMass===null?{}:{UnladenMass:input.unladenMass},...input.cargoCapacity===null?{}:{CargoCapacity:input.cargoCapacity},...input.maxJumpRange===null?{}:{MaxJumpRange:input.maxJumpRange},...input.fuelCapacity===null?{}:{FuelCapacity:{Main:input.fuelCapacity.main,Reserve:input.fuelCapacity.reserve}},...rebuy===null?{}:{Rebuy:rebuy},Modules:exportModules(input,options,fromSource)}}function exportModules(input,options,fromSource){const ordered=options.moduleOrder==="slots"?slotOrderedModules(input.modules,input.layout):[...input.modules.values()];return ordered.map(module=>{const on=module.On??(options.explicitPower?true:void 0);const priority=module.Priority??(options.explicitPower?0:void 0);const value=fromSource?sourceModuleValue(module,input.sourcePurchase):moduleValue(module,input.statsFor);return{Slot:module.Slot,Item:module.Item.toLowerCase(),...on===void 0?{}:{On:on},...priority===void 0?{}:{Priority:priority},...module.Health===void 0?{}:{Health:module.Health},...typeof value==="number"?{Value:value}:{},...module.Engineering===void 0?{}:{Engineering:cloneLoadoutModule(module).Engineering}}})}function slotOrderedModules(modules,layout){return orderBySlotLayout([...modules.values()],layout,module=>module.Slot)}function computedModulesValue(modules,statsFor){let sum=0;for(const module of modules.values()){const value=moduleValue(module,statsFor);if(value==="unknown")return null;if(value!=="free")sum+=value}return sum}function moduleValue(module,statsFor){const stats=statsFor(module);if(stats!==null)return stats.cost??"unknown";return isNonOutfittingSlot(module.Slot)||isBuiltInHullModule(module)?"free":"unknown"}var SOURCE_ITEM="ShipLoadout: sourcePurchase moduleValues[].item";function sourceModuleValue(module,source){const entry=source===null?null:getSourceModuleValue(source,module.Slot);if(entry===null)return"unknown";return normalizeKey(entry.item,SOURCE_ITEM)===normalizeKey(module.Item,FITTED_ITEM)?entry.value:"unknown"}function sourceTotalsHold(modules,source){for(const entry of source.moduleValues){const key=matchingKeyIn(modules,entry.slot);const fitted=key===null?void 0:modules.get(key);if(!fitted)return false;if(isCargoHatchSlot(entry.slot)&&entry.value===0)continue;if(normalizeKey(fitted.Item,FITTED_ITEM)!==normalizeKey(entry.item,SOURCE_ITEM)){return false}}return true}function captureLoadoutEvent(event){const modules=event.Modules;const shipName=event.ShipName;const shipIdent=event.ShipIdent;const hullValue=event.HullValue;const modulesValue=event.ModulesValue;const rebuy=event.Rebuy;const unladenMass=event.UnladenMass;const cargoCapacity=event.CargoCapacity;const fuelCapacity=event.FuelCapacity;return{Ship:event.Ship,Modules:Array.isArray(modules)?captureEach(modules,captureModule):modules,...shipName===void 0?{}:{ShipName:shipName},...shipIdent===void 0?{}:{ShipIdent:shipIdent},...hullValue===void 0?{}:{HullValue:hullValue},...modulesValue===void 0?{}:{ModulesValue:modulesValue},...rebuy===void 0?{}:{Rebuy:rebuy},...unladenMass===void 0?{}:{UnladenMass:unladenMass},...cargoCapacity===void 0?{}:{CargoCapacity:cargoCapacity},...fuelCapacity===void 0?{}:{FuelCapacity:{...fuelCapacity}}}}function captureEach(values,capture){const captured=[];const{length:length}=values;for(let index=0;index<length;index++)captured.push(capture(values[index]));return captured}function captureModule(module){if(module===null||typeof module!=="object")return module;const on=module.On;const priority=module.Priority;const health=module.Health;const value=module.Value;const engineering=module.Engineering;return{Slot:module.Slot,Item:module.Item,...on===void 0?{}:{On:on},...priority===void 0?{}:{Priority:priority},...health===void 0?{}:{Health:health},...value===void 0?{}:{Value:value},...engineering===void 0?{}:{Engineering:captureEngineering(engineering)}}}function captureEngineering(engineering){if(engineering===null||typeof engineering!=="object")return engineering;const experimental=engineering.ExperimentalEffect;const experimentalLocalised=engineering.ExperimentalEffect_Localised;const modifiers=engineering.Modifiers;return{BlueprintName:engineering.BlueprintName,Level:engineering.Level,Quality:engineering.Quality,...experimental===void 0?{}:{ExperimentalEffect:experimental},...experimentalLocalised===void 0?{}:{ExperimentalEffect_Localised:experimentalLocalised},...modifiers===void 0?{}:{Modifiers:Array.isArray(modifiers)?captureEach(modifiers,modifier=>modifier!==null&&typeof modifier==="object"?{...modifier}:modifier):modifiers}}}function normalizeLoadoutEvent(rawEvent){const event=captureLoadoutEvent(rawEvent);requireString(event.Ship,"ShipLoadout.fromLoadout: event.Ship");if(!Array.isArray(event.Modules)){throw new TypeError(`ShipLoadout.fromLoadout: event.Modules must be an array, received ${describeValue(event.Modules)}`)}const modules=/* @__PURE__ */new Map;const slots=/* @__PURE__ */new Set;for(const module of event.Modules){if(module===null||typeof module!=="object"){throw new TypeError(`ShipLoadout.fromLoadout: event.Modules[] must hold module objects, received ${describeValue(module)}`)}requireString(module.Slot,"ShipLoadout.fromLoadout: module.Slot");requireString(module.Item,"ShipLoadout.fromLoadout: module.Item");if(module.Engineering!==void 0){if(module.Engineering===null||typeof module.Engineering!=="object"){throw new TypeError(`ShipLoadout.fromLoadout: module.Engineering must be an object, received ${describeValue(module.Engineering)}`)}requireStringIfPresent(module.Engineering.BlueprintName,"ShipLoadout.fromLoadout: module.Engineering.BlueprintName");requireStringIfPresent(module.Engineering.ExperimentalEffect,"ShipLoadout.fromLoadout: module.Engineering.ExperimentalEffect");if(module.Engineering.Modifiers!==void 0&&!Array.isArray(module.Engineering.Modifiers)){throw new TypeError(`ShipLoadout.fromLoadout: module.Engineering.Modifiers must be an array, received ${describeValue(module.Engineering.Modifiers)}`)}for(const[index,modifier]of(module.Engineering.Modifiers??[]).entries()){if(modifier===null||typeof modifier!=="object"){throw new TypeError(`ShipLoadout.fromLoadout: module.Engineering.Modifiers[${index}] must be an object, received ${describeValue(modifier)}`)}requireString(modifier.Label,`ShipLoadout.fromLoadout: module.Engineering.Modifiers[${index}].Label`)}}const normalizedSlot=module.Slot.toLowerCase();if(slots.has(normalizedSlot)){throw new TypeError(`ShipLoadout.fromLoadout: duplicate slot "${truncate(module.Slot)}"`)}slots.add(normalizedSlot);modules.set(module.Slot,cloneLoadoutModule(module))}const top={};if(event.ShipName!==void 0)top.ShipName=event.ShipName;if(event.ShipIdent!==void 0)top.ShipIdent=event.ShipIdent;if(event.HullValue!==void 0)top.HullValue=event.HullValue;if(event.ModulesValue!==void 0)top.ModulesValue=event.ModulesValue;if(event.Rebuy!==void 0)top.Rebuy=event.Rebuy;if(event.UnladenMass!==void 0)top.UnladenMass=event.UnladenMass;if(event.CargoCapacity!==void 0)top.CargoCapacity=event.CargoCapacity;if(event.FuelCapacity!==void 0)top.FuelCapacity={...event.FuelCapacity};const moduleStats=/* @__PURE__ */new Map;const primitiveModifiers=/* @__PURE__ */new Map;for(const module of modules.values()){const engineering=module.Engineering;const variant=identifyPreEngineeredVariant(module);const catalogueVariantStats=variant?getPreEngineeredStats(variant):null;let variantStats=catalogueVariantStats;const retainsBakedExperimental=variant?.experimental!==void 0&&typeof engineering?.ExperimentalEffect==="string"&&variant.experimental.trim().toLowerCase()===engineering.ExperimentalEffect.trim().toLowerCase();if(variant&&catalogueVariantStats&&!catalogueVariantStats.engineeringLocked&&!retainsBakedExperimental){const{experimental:originalExperimental,...withoutExperimental}=variant;const currentExperimental=engineering?.ExperimentalEffect;const currentVariant=typeof currentExperimental==="string"?{...withoutExperimental,experimental:currentExperimental}:withoutExperimental;variantStats=getPreEngineeredStats(withoutExperimental);primitiveModifiers.set(module.Slot,[...engineering?.Modifiers??[],...getPreEngineeredModifiers(currentVariant)])}if(variantStats)moduleStats.set(module.Slot,cloneModuleStats(variantStats));const guardianFinal=typeof engineering?.BlueprintName==="string"&&isFinalGuardianWeaponEngineering(module.Item,engineering.BlueprintName);if(variantStats?.engineeringLocked||typeof engineering?.BlueprintName!=="string"||!guardianFinal){continue}const normalizedBlueprint=normalizeKey(engineering.BlueprintName,"ShipLoadout.fromLoadout: module.Engineering.BlueprintName");const normalizedExperimental=normalizeKey(engineering.ExperimentalEffect,"ShipLoadout.fromLoadout: module.Engineering.ExperimentalEffect");const variants=getPreEngineeredVariants(module.Item);const exact=variants.find(candidate=>candidate.engineeringLocked===true&&candidate.blueprint.toLowerCase()===normalizedBlueprint&&candidate.grade===engineering.Level&&candidate.experimental?.toLowerCase()===normalizedExperimental);const guardianBase=variants.find(candidate=>candidate.engineeringLocked===true&&candidate.blueprint.toLowerCase()===normalizedBlueprint&&candidate.grade===engineering.Level&&candidate.experimental===void 0);const stats=exact?getPreEngineeredStats(exact):guardianBase&&engineering.ExperimentalEffect!==void 0?getPreEngineeredStats({...guardianBase,experimental:engineering.ExperimentalEffect}):builtInModuleBySymbol(module.Item,"ShipLoadout.fromLoadout: module.Item");if(stats){moduleStats.set(module.Slot,cloneModuleStats({...stats,engineeringLocked:true}))}}return{shipSymbol:event.Ship,modules:modules,moduleStats:moduleStats,primitiveModifiers:primitiveModifiers,top:top,sourcePurchase:sourcePurchaseFromLoadout(event)}}var SLOT_KEY="ShipLoadout: slotKey";var requireLoadOptions=(scope,options)=>{for(const field of["fuel","cargo"]){const value=options[field];if(value!==void 0&&(!Number.isFinite(value)||value<0)){throw new RangeError(`${scope}: ${field} must be a finite non-negative number`)}}};var requireEnginesPips=(scope,enginesPips)=>{if(!Number.isFinite(enginesPips)||enginesPips<0||enginesPips>4){throw new RangeError(`${scope}: enginesPips must be a finite number from 0 to 4`)}return enginesPips};var requireSystemsPips=(scope,systemsPips)=>{if(!Number.isFinite(systemsPips)||systemsPips<0||systemsPips>4){throw new RangeError(`${scope}: systemsPips must be a finite number from 0 to 4`)}return systemsPips};var LoadoutEditError=class extends TypeError{code;constraint;params;constructor(message,code,params,constraint){super(message);this.code=code;this.params=deepFreeze(structuredClone(params));if(constraint!==void 0)this.constraint=constraint}};var experimentalEffectUnsupported=(code,params)=>deepFreeze({kind:"unsupported",code:code,params:params});var engineeringNormalizationUnsupported=(code,params)=>deepFreeze({kind:"unsupported",code:code,params:params});var FSD_PREFIX="int_hyperdrive";var BOOSTER_PREFIX="int_guardianfsdbooster";var FUEL_TANK_PREFIX="int_fueltank";var ShipLoadout=class _ShipLoadout{#ship;#shipSymbol;#modules;#moduleStats;#primitiveModifiers;#top;#sourcePurchase;#slotCache=/* @__PURE__ */new Map;#layoutCache;constructor(ship,shipSymbol,modules,top,sourcePurchase=null,moduleStats=/* @__PURE__ */new Map,primitiveModifiers=/* @__PURE__ */new Map){this.#ship=ship;this.#shipSymbol=shipSymbol;this.#modules=modules;this.#top=top;this.#sourcePurchase=sourcePurchase;this.#moduleStats=moduleStats;this.#primitiveModifiers=primitiveModifiers}static fromSlef(input,index=0){const entries=parseSlef(input);const entry=entries[index];if(!entry){throw new TypeError(`ShipLoadout.fromSlef: no entry at index ${truncate(index)} (have ${entries.length})`)}const imported=normalizeLoadoutEvent(entry.data);const ship=getShipBySymbol(imported.shipSymbol);if(!ship){throw new TypeError(`ShipLoadout.fromSlef: unknown hull "${truncate(imported.shipSymbol)}"`)}return _ShipLoadout.#fromImported(imported,ship)}static fromLoadout(event){if(event===null||typeof event!=="object"){throw new TypeError(`ShipLoadout.fromLoadout: event must be a Loadout event, received ${describeValue(event)}`)}const imported=normalizeLoadoutEvent(event);const ship=getShipBySymbol(imported.shipSymbol);if(!ship){throw new TypeError(`ShipLoadout.fromLoadout: unknown hull "${truncate(imported.shipSymbol)}"`)}return _ShipLoadout.#fromImported(imported,ship)}static#fromImported(imported,ship){const defaultHatch=getDefaultLoadout(imported.shipSymbol)?.modules.find(module=>isCargoHatchSlot(module.slot));const capturedHatchKey=defaultHatch===void 0?null:matchingKeyIn(imported.modules,defaultHatch.slot);const capturedHatch=capturedHatchKey===null?void 0:imported.modules.get(capturedHatchKey);if(defaultHatch&&capturedHatch===void 0){const ownSlot=ownKeyIn(imported.modules,defaultHatch.slot);imported.modules.set(ownSlot,{Slot:ownSlot,Item:defaultHatch.symbol})}const build=new _ShipLoadout(ship,imported.shipSymbol,imported.modules,imported.top,imported.sourcePurchase,imported.moduleStats,imported.primitiveModifiers);if(capturedHatch!==void 0&&!isBuiltInHullModule(capturedHatch)){build.repairFixedMount(capturedHatch.Slot)}return build}static empty(shipSymbol){const requested=requireString(shipSymbol,"ShipLoadout.empty: shipSymbol");const ship=getShipBySymbol(requested);if(!ship){throw new TypeError(`ShipLoadout.empty: no slot layout for hull "${truncate(shipSymbol)}"`)}const hatch=getDefaultLoadout(ship.symbol)?.modules.find(module=>isCargoHatchSlot(module.slot));const modules=/* @__PURE__ */new Map;if(hatch){modules.set(hatch.slot,{Slot:hatch.slot,Item:hatch.symbol})}return new _ShipLoadout(ship,ship.symbol,modules,{})}static default(shipSymbol){const requested=requireString(shipSymbol,"ShipLoadout.default: shipSymbol");const ship=getShipBySymbol(requested);if(!ship){throw new TypeError(`ShipLoadout.default: no default loadout for hull "${truncate(shipSymbol)}"`)}const loadout=getDefaultLoadout(ship.symbol);return new _ShipLoadout(ship,loadout.symbol,new Map(loadout.modules.map(module=>[module.slot,{Slot:module.slot,Item:module.symbol}])),{})}get shipSymbol(){return this.#shipSymbol}get shipName(){return this.#top.ShipName??null}get shipIdent(){return this.#top.ShipIdent??null}get unladenMass(){return this.unladenMassResult.value}get unladenMassResult(){return this.#top.UnladenMass===void 0?this.#computedUnladenMass():completeResult(this.#top.UnladenMass)}#computedUnladenMass(){return calculateUnladenMass(this.#ship.hullMass,this.#calculationModules())}get fuelCapacity(){return this.fuelCapacityResult.value}get fuelCapacityResult(){const cap=this.#top.FuelCapacity;if(cap?.Main!==void 0&&cap.Reserve!==void 0){return completeResult(Object.freeze({main:cap.Main,reserve:cap.Reserve}))}const computed=this.#computedFuelCapacity();if(computed.value===null)return computed;return completeResult(Object.freeze({main:cap?.Main??computed.value.main,reserve:cap?.Reserve??computed.value.reserve}))}get cargoCapacity(){return this.cargoCapacityResult.value}get cargoCapacityResult(){return this.#top.CargoCapacity===void 0?this.#computedCargoCapacity():completeResult(this.#top.CargoCapacity)}#computedCargoCapacity(){return calculateCargoCapacity(this.#calculationModules())}#computedFuelCapacity(){return calculateFuelCapacity(this.#ship.reserveFuelCapacity,this.#calculationModules())}get hullValue(){return this.#top.HullValue??null}get modulesValue(){return this.#top.ModulesValue??null}get rebuy(){return this.#top.Rebuy??null}get sourcePurchase(){return this.#sourcePurchase}get validation(){const slots=this.#layout();const byKey=new Map(slots.map(slot=>[slot.key.toLowerCase(),slot]));const modules=[...this.#modules.values()].map(module=>{const stats=this.#statsFor(module);const slot=byKey.get(module.Slot.toLowerCase());const builtIn=stats===null&&isNonOutfittingSlot(module.Slot)||isBuiltInHullModule(module);const fitProblem=stats&&slot&&!builtIn?moduleFitProblem(this.#shipSymbol,slot,stats):null;return{slot:module.Slot,symbol:module.Item,known:stats!==null||builtIn,requiresKnownSlot:!builtIn,fitError:fitProblem?.message??null,...fitProblem===null?{}:{fitConstraint:fitProblem.constraint},...fitProblem?.params===void 0?{}:{fitParams:fitProblem.params},...stats?.exclusionGroup===void 0?{}:{exclusionGroup:stats.exclusionGroup},...stats?.limitGroup===void 0?{}:{limitGroup:stats.limitGroup},...stats?.limitIncrease===void 0?{}:{limitIncrease:stats.limitIncrease}}});return validateLoadout({shipSymbol:this.#shipSymbol,slots:slots,modules:modules})}slots(kind){const cached=this.#slotCache.get(kind);if(cached!==void 0)return cached;const slots=kind===void 0?this.#layout():this.#layout().filter(slot=>slot.kind===kind);const currentLimits=this.#moduleLimits();const value=deepFreeze(slots.map(slot=>{const stats=this.#moduleStatsAt(slot.key);const fixedReason=fixedSlotReason(slot);const immovableReason=fixedReason!==null?fixedReason:stats?.limitIncrease!==void 0&&this.#moduleLimitRegression(slot.key,null,currentLimits,stats)!==null?"moduleLimit":null;return{...slot,name:loadoutSlotName(slot),module:this.fittedModuleAt(slot.key),removable:immovableReason===null,...immovableReason===null?{}:{immovableReason:immovableReason}}}));this.#slotCache.set(kind,value);return value}fittedModuleAt(slotKey){const module=this.#fittedModuleFor(slotKey);if(!module)return null;const raw=cloneLoadoutModule(module);const stats=this.#statsFor(module);const effective=effectiveModule(this.#moduleForEffectiveStats(module),stats);return deepFreeze({slot:module.Slot,symbol:raw.Item,on:raw.On,priority:raw.Priority,health:raw.Health,value:raw.Value,engineering:raw.Engineering,raw:raw,stats:stats===null?null:cloneModuleStats(stats),effectiveStats:effective===null?null:cloneModuleStats(effective),ammunition:ammunitionCapacity(effective),preEngineeredVariant:identifyPreEngineeredVariant(raw)})}fittedModules(){return deepFreeze([...this.#modules.keys()].flatMap(key=>{const fitted=this.fittedModuleAt(key);return fitted===null?[]:[fitted]}))}availableBlueprints(slotKey){const module=this.#fittedModuleFor(slotKey);return deepFreeze(module?availableBlueprintsFor(module.Item,this.#statsFor(module)):[])}availableExperimentalEffects(slotKey){const module=this.#fittedModuleFor(slotKey);return deepFreeze(module?availableExperimentalsFor(module.Item,this.#statsFor(module)):[])}modulesForSlot(slotKey){const slot=this.#requireSlot(slotKey);const occupied=new Set([...this.#modules.values()].flatMap(fitted=>{if(fitted.Slot.toLowerCase()===slot.key.toLowerCase())return[];const group=this.#statsFor(fitted)?.exclusionGroup;return group===void 0?[]:[group]}));const currentLimits=this.#moduleLimits();const currentStats=this.#moduleStatsAt(slot.key);return ALL_MODULES.filter(module=>moduleFitError(this.#shipSymbol,slot,module)===null&&(module.exclusionGroup===void 0||!occupied.has(module.exclusionGroup))&&this.#moduleLimitRegression(slot.key,module,currentLimits,currentStats)===null)}repairFixedMount(slotKey){const requested=requireString(slotKey,SLOT_KEY);const wanted=requested.toLowerCase();const slot=this.#requireSlot(requested);const fittedKey=this.#fittedKey(requested);const resultSlot=fittedKey??requested;const canonicalKey=slot.key;if(fixedSlotReason(slot)===null){return deepFreeze({status:"refused",slot:resultSlot,reason:"notFixedMount"})}const current=this.#fittedModuleFor(requested);const currentStats=current?this.#statsFor(current):null;const valid=current!==void 0&&currentStats!==null&&(slot.kind==="cargoHatch"?isBuiltInHullModule(current):moduleFitProblem(this.#shipSymbol,slot,currentStats)===null);if(valid){return deepFreeze({status:"unchanged",slot:current.Slot,symbol:current.Item})}const defaultModule=getDefaultLoadout(this.#shipSymbol)?.modules.find(module=>module.slot.toLowerCase()===wanted);if(!defaultModule){return deepFreeze({status:"defaultUnavailable",slot:resultSlot})}const ownKey=ownKeyIn(this.#modules,canonicalKey);const replacement={Slot:ownKey,Item:defaultModule.symbol,...current?.On===void 0?{}:{On:current.On},...current?.Priority===void 0?{}:{Priority:current.Priority},...current?.Health===void 0?{}:{Health:current.Health}};const replacementStats=builtInModuleBySymbol(defaultModule.symbol,"ShipLoadout.repairFixedMount")??(isBuiltInHullModule(replacement)?builtInModuleBySymbol("ModularCargoBayDoor","ShipLoadout.repairFixedMount"):null);if(!replacementStats){return deepFreeze({status:"defaultUnavailable",slot:resultSlot,symbol:defaultModule.symbol})}this.#replaceModule(ownKey,replacement,replacementStats);return deepFreeze({status:"repaired",slot:ownKey,symbol:defaultModule.symbol})}setModule(slotKey,module){const slot=this.#requireSlot(slotKey);if(module===null||module===void 0){throw new TypeError(`ShipLoadout.setModule: no module supplied for "${truncate(slotKey)}" (did the module lookup return undefined?)`)}if(typeof module.symbol!=="string"){throw new TypeError(`ShipLoadout.setModule: module for "${truncate(slotKey)}" must be an outfitting module, received ${describeValue(module)}`)}const problem2=moduleFitProblem(this.#shipSymbol,slot,module);if(problem2){if(problem2.constraint==="immutableSlot"){throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${problem2.message}`,"immutableSlot",{slot:slot.key})}throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${problem2.message}`,"incompatibleModule",{...problem2.params,slot:slot.key,symbol:module.symbol,constraint:problem2.constraint},problem2.constraint)}if(module.exclusionGroup!==void 0){const conflict=[...this.#modules.values()].find(fitted=>fitted.Slot.toLowerCase()!==slot.key.toLowerCase()&&this.#statsFor(fitted)?.exclusionGroup===module.exclusionGroup);if(conflict){throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${module.exclusionGroup} is limited to one per ship (already fitted in ${truncate(conflict.Slot)})`,"duplicateExclusiveModule",{exclusionGroup:module.exclusionGroup,slot:slot.key,symbol:module.symbol,previousSlot:conflict.Slot,previousSymbol:conflict.Item})}}const limitProblem=this.#moduleLimitRegression(slot.key,module);if(limitProblem!==null){throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${limitProblem.group} would have ${limitProblem.count} modules but the ship allows ${limitProblem.limit}`,"moduleLimitExceeded",{group:limitProblem.group,count:limitProblem.count,limit:limitProblem.limit,slot:slot.key,symbol:module.symbol})}const key=this.#fittedKey(slotKey)??slot.key;this.#replaceModule(key,{Slot:key,Item:module.symbol},cloneModuleStats(module));return this}removeModule(slotKey){const wanted=requireString(slotKey,SLOT_KEY).toLowerCase();if(wanted==="cargohatch"){throw new LoadoutEditError("ShipLoadout.removeModule: the cargoHatch slot cannot be changed","immutableSlot",{slot:"CargoHatch"})}const parsed=parseSlotName(slotKey);const slot=this.#layout().find(candidate=>candidate.key.toLowerCase()===wanted);if(parsed!==null&&fixedSlotReason(parsed)==="requiredSlot"){const fittedKey=this.#fittedKey(slotKey);const key2=slot?.key??fittedKey??slotKey;throw new LoadoutEditError(`ShipLoadout.removeModule: the ${truncate(key2)} slot is required and cannot be emptied`,"requiredSlot",{slot:key2})}const key=this.#fittedKey(slotKey);if(key!==null){const limitProblem=this.#moduleLimitRegression(key,null);if(limitProblem!==null){const fitted=this.#modules.get(key);throw new LoadoutEditError(`ShipLoadout.removeModule: ${truncate(slotKey)}: ${limitProblem.group} would have ${limitProblem.count} modules but the ship allows ${limitProblem.limit}`,"moduleLimitExceeded",{group:limitProblem.group,count:limitProblem.count,limit:limitProblem.limit,slot:key,...fitted===void 0?{}:{symbol:fitted.Item}})}this.#replaceModule(key,null)}return this}applyBlueprint(slotKey,fdname,options){requireString(fdname,"ShipLoadout.applyBlueprint: fdname");if(options===null||typeof options!=="object"){throw new TypeError(`ShipLoadout.applyBlueprint: options must be an object with a grade, received ${describeValue(options)}`)}const wantedGrade=options.grade;const wantedQuality=options.quality;const wantedExperimental=options.experimental??void 0;requireStringIfPresent(wantedExperimental,"ShipLoadout.applyBlueprint: options.experimental");const module=this.#fittedModuleFor(slotKey);if(!module){throw new RangeError(`ShipLoadout.applyBlueprint: slot "${truncate(slotKey)}" is empty`)}const fittedStats=this.#statsFor(module);if(!fittedStats){throw new TypeError(`ShipLoadout.applyBlueprint: no stats for module "${truncate(module.Item)}"`)}const recipe=resolveBlueprintForModule(module.Item,fdname);const named=recipe===fdname?`"${truncate(fdname)}"`:`"${truncate(fdname)}" (${truncate(recipe)} on this module)`;const written=fdname.trim().toLowerCase();const resolved=recipe.trim().toLowerCase();if(getPreEngineeredVariants(module.Item).some(variant=>variant.acquisition==="eventReward"&&(variant.blueprint.toLowerCase()===written||variant.blueprint.toLowerCase()===resolved))){throw new TypeError(`ShipLoadout.applyBlueprint: ${named} is a fixed pre-engineered identity, not a craftable blueprint; use setPreEngineeredVariant to fit its fixed article`)}if(!Number.isInteger(wantedGrade)||wantedGrade<1||wantedGrade>5){throw new RangeError(`ShipLoadout.applyBlueprint: no blueprint ${named} grade ${truncate(wantedGrade)}`)}const grade=getBlueprintGrade(recipe,wantedGrade);if(!grade){throw new RangeError(`ShipLoadout.applyBlueprint: no blueprint ${named} grade ${truncate(wantedGrade)}`)}let experimental;if(wantedExperimental!==void 0){experimental=getExperimentalEffect(wantedExperimental);if(!experimental){throw new RangeError(`ShipLoadout.applyBlueprint: unknown experimental effect "${truncate(wantedExperimental)}"`)}}const quality=wantedQuality??1;if(!Number.isFinite(quality)||quality<0||quality>1){throw new RangeError(`ShipLoadout.applyBlueprint: quality must be a finite number in [0, 1]`)}if(fittedStats.engineeringLocked){throw new TypeError(`ShipLoadout.applyBlueprint: module "${truncate(module.Item)}" is a final pre-engineered article and accepts no further engineering`)}if(!blueprintAvailableFor(module.Item,fdname)){const offered=[...blueprintRoutesFor(module.Item)].map(([blueprint,route])=>`${blueprint} (${route})`);throw new TypeError(offered.length>0?`ShipLoadout.applyBlueprint: module "${truncate(module.Item)}" is not offered blueprint ${named}; available candidates are ${offered.join(", ")}`:`ShipLoadout.applyBlueprint: no registry lists an engineering menu for module "${truncate(module.Item)}"`)}if(wantedExperimental!==void 0&&!experimentalAvailableFor(module.Item,wantedExperimental)){const offered=getExperimentalsForModule(module.Item);throw new TypeError(`ShipLoadout.applyBlueprint: module "${truncate(module.Item)}" is not offered experimental effect "${truncate(wantedExperimental)}"; it takes ${offered.length>0?offered.join(", "):"no experimental effect"}`)}const stats=this.#engineeringBaseStats(module)??fittedStats;const base=baseStats(stats);const canonical=primitiveEngineeringInputsFor(stats,grade,experimental);const missing=missingBaseLabels(stats,base,canonical.grade.features,canonical.experimental?.modifiers);if(missing.length>0){throw new TypeError(`ShipLoadout.applyBlueprint: cannot compute ${named} for module "${truncate(module.Item)}"; missing base stats for ${missing.join(", ")}`)}const damageDistribution=experimental?.damageDistribution??grade.damageDistribution;const primitiveModifiers=computeModifiers(base,canonical.grade,quality,canonical.experimental);const modifiers=journalModifiersFor(stats,primitiveModifiers);if(damageDistribution){for(const type of["kinetic","thermal","explosive","absolute"]){const value=damageDistribution[type];if(value===void 0)continue;const label=labelsForDamageType(type)[0];if(label===void 0)continue;const damageModifier={Label:label,Value:value*scaleForLabel(label),OriginalValue:(stats.damageDistribution?.[type]??0)*scaleForLabel(label)};modifiers.push(damageModifier);primitiveModifiers.push(damageModifier)}}const engineering={BlueprintName:fdname,Level:wantedGrade,Quality:quality,...wantedExperimental!==void 0?{ExperimentalEffect:wantedExperimental}:{},Modifiers:modifiers};this.#replaceModule(module.Slot,{...module,Engineering:engineering},stats,primitiveModifiers);return this}setExperimentalEffect(slotKey,experimental){if(experimental!==null){requireString(experimental,"ShipLoadout.setExperimentalEffect: experimental")}const wanted=experimental;const module=this.#fittedModuleFor(slotKey);if(!module)return experimentalEffectUnsupported("emptySlot",{slot:slotKey});const stats=this.#statsFor(module);if(!stats){return experimentalEffectUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const engineering=module.Engineering;if(!engineering){return experimentalEffectUnsupported("notEngineered",{slot:module.Slot,symbol:module.Item})}if(stats.engineeringLocked){return experimentalEffectUnsupported("finalArticle",{slot:module.Slot,symbol:module.Item})}const previous=engineering.ExperimentalEffect??null;if(previous===null&&wanted===null||previous!==null&&wanted!==null&&previous.trim().toLowerCase()===wanted.trim().toLowerCase()){return deepFreeze({kind:"unchanged",experimental:previous})}const variant=identifyPreEngineeredVariant(module);let effect;if(wanted!==null){effect=getExperimentalEffect(wanted);if(!effect){return experimentalEffectUnsupported("unknownExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:wanted})}const restoresBakedEffect=variant?.experimental!==void 0&&variant.experimental.trim().toLowerCase()===wanted.trim().toLowerCase();if(!experimentalAvailableFor(module.Item,wanted)&&!restoresBakedEffect){return experimentalEffectUnsupported("unsupportedExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:wanted})}}if(variant&&variant.acquisition!=="mercenary"){const stock=this.#engineeringBaseStats(module);if(!stock){return experimentalEffectUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const missing=missingBaseLabels(stock,baseStats(stock),[],effect?.modifiers);if(missing.length>0){return experimentalEffectUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}const{experimental:originalEffect,...withoutEffect}=variant;const adjusted=wanted===null?withoutEffect:{...withoutEffect,experimental:wanted};const resolved=getPreEngineeredStats(withoutEffect);if(!resolved){return experimentalEffectUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const replacement={BlueprintName:engineering.BlueprintName,Level:engineering.Level,Quality:engineering.Quality,...wanted===null?{}:{ExperimentalEffect:wanted},Modifiers:getPreEngineeredJournalModifiers(adjusted)};this.#replaceModule(module.Slot,{...module,Engineering:replacement},cloneModuleStats(resolved),getPreEngineeredModifiers(adjusted))}else{const blueprint=engineering.BlueprintName;const grade=engineering.Level;const quality=engineering.Quality;if(typeof blueprint!=="string"||!Number.isInteger(grade)||grade<1||grade>5){return experimentalEffectUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const currentEffect=previous===null?void 0:getExperimentalEffect(previous)??null;if(ordinaryEngineeringProof(module.Item,engineering,currentEffect)==="unproven"){return experimentalEffectUnsupported("unidentifiedPreEngineeredVariant",{slot:module.Slot,symbol:module.Item,blueprint:blueprint})}const recipe=resolveBlueprintForModule(module.Item,blueprint);const blueprintGrade=getBlueprintGrade(recipe,grade);if(!blueprintGrade||!blueprintAvailableFor(module.Item,blueprint)||!Number.isFinite(quality)||quality<0||quality>1){return experimentalEffectUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item,blueprint:blueprint,grade:grade})}const base=this.#engineeringBaseStats(module)??stats;const canonical=primitiveEngineeringInputsFor(base,blueprintGrade,effect);const missing=missingBaseLabels(base,baseStats(base),canonical.grade.features,canonical.experimental?.modifiers);if(missing.length>0){return experimentalEffectUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}this.applyBlueprint(module.Slot,blueprint,{grade:grade,quality:quality,...wanted===null?{}:{experimental:wanted}})}return deepFreeze({kind:"updated",previousExperimental:previous,experimental:wanted})}completeEngineeringGrade(slotKey){const module=this.#fittedModuleFor(slotKey);if(!module)return engineeringNormalizationUnsupported("emptySlot",{slot:slotKey});const stats=this.#statsFor(module);if(!stats){return engineeringNormalizationUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const engineering=module.Engineering;if(!engineering){return engineeringNormalizationUnsupported("notEngineered",{slot:module.Slot,symbol:module.Item})}if(stats.engineeringLocked){return engineeringNormalizationUnsupported("finalArticle",{slot:module.Slot,symbol:module.Item})}if(engineering.Quality===1){return deepFreeze({kind:"unchanged"})}const previousQuality=engineering.Quality;if(!Number.isFinite(previousQuality)||previousQuality<0||previousQuality>1){return engineeringNormalizationUnsupported("invalidQuality",{slot:module.Slot,symbol:module.Item})}const experimental=engineering.ExperimentalEffect??null;const effect=experimental===null?void 0:getExperimentalEffect(experimental)??void 0;if(experimental!==null&&!effect){return engineeringNormalizationUnsupported("unknownExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:experimental})}const blueprint=engineering.BlueprintName;const grade=engineering.Level;if(typeof blueprint!=="string"||!Number.isInteger(grade)||grade<1||grade>5){return engineeringNormalizationUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const variant=identifyPreEngineeredVariant(module);const restoresBakedEffect=variant?.experimental!==void 0&&variant.experimental.trim().toLowerCase()===experimental?.trim().toLowerCase();if(experimental!==null&&!experimentalAvailableFor(module.Item,experimental)&&!restoresBakedEffect){return engineeringNormalizationUnsupported("unsupportedExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:experimental})}if(variant&&variant.acquisition!=="mercenary"){const stock=this.#engineeringBaseStats(module);if(!stock){return engineeringNormalizationUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const missing=missingBaseLabels(stock,baseStats(stock),[],effect?.modifiers);if(missing.length>0){return engineeringNormalizationUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}const{experimental:originalEffect,...withoutEffect}=variant;const adjusted=experimental===null?withoutEffect:{...withoutEffect,experimental:experimental};const resolved=getPreEngineeredStats(withoutEffect);if(!resolved){return engineeringNormalizationUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const replacement={BlueprintName:engineering.BlueprintName,Level:engineering.Level,Quality:1,...experimental===null?{}:{ExperimentalEffect:experimental},Modifiers:getPreEngineeredJournalModifiers(adjusted)};this.#replaceModule(module.Slot,{...module,Engineering:replacement},cloneModuleStats(resolved),getPreEngineeredModifiers(adjusted))}else{const proof=ordinaryEngineeringProof(module.Item,engineering,effect);if(proof==="unproven"||proof==="proven"&&!blueprintAvailableFor(module.Item,blueprint)){return engineeringNormalizationUnsupported("unidentifiedPreEngineeredVariant",{slot:module.Slot,symbol:module.Item,blueprint:blueprint})}const recipe=resolveBlueprintForModule(module.Item,blueprint);const blueprintGrade=getBlueprintGrade(recipe,grade);if(!blueprintGrade||!blueprintAvailableFor(module.Item,blueprint)){return engineeringNormalizationUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item,blueprint:blueprint,grade:grade})}const base=this.#engineeringBaseStats(module)??stats;const canonical=primitiveEngineeringInputsFor(base,blueprintGrade,effect);const missing=missingBaseLabels(base,baseStats(base),canonical.grade.features,canonical.experimental?.modifiers);if(missing.length>0){return engineeringNormalizationUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}this.applyBlueprint(module.Slot,blueprint,{grade:grade,quality:1,...experimental===null?{}:{experimental:experimental}})}return deepFreeze({kind:"normalized",previousQuality:previousQuality,quality:1})}setPreEngineeredVariant(slotKey,variant){if(variant===null||typeof variant!=="object"){throw new TypeError(`ShipLoadout.setPreEngineeredVariant: variant must be a pre-engineered variant, received ${describeValue(variant)}`)}requireString(variant.symbol,"ShipLoadout.setPreEngineeredVariant: variant.symbol");requireString(variant.blueprint,"ShipLoadout.setPreEngineeredVariant: variant.blueprint");requireString(variant.acquisition,"ShipLoadout.setPreEngineeredVariant: variant.acquisition");requireStringIfPresent(variant.experimental,"ShipLoadout.setPreEngineeredVariant: variant.experimental");const known=getPreEngineeredVariants(variant.symbol).find(candidate=>candidate.blueprint.toLowerCase()===variant.blueprint.toLowerCase()&&candidate.grade===variant.grade&&(candidate.experimental?.toLowerCase()??"")===(variant.experimental?.toLowerCase()??"")&&candidate.acquisition===variant.acquisition);if(!known){throw new RangeError(`ShipLoadout.setPreEngineeredVariant: no catalogued variant "${truncate(variant.blueprint)}" for module "${truncate(variant.symbol)}"`)}const stats=getPreEngineeredStats(known);const unresolved=unresolvedModifiers(known);if(unresolved.length>0){throw new TypeError(`ShipLoadout.setPreEngineeredVariant: cannot resolve "${truncate(variant.blueprint)}" for module "${truncate(variant.symbol)}"; missing base stats for ${unresolved.join(", ")}`)}this.setModule(slotKey,stats);const module=this.#fittedModuleFor(slotKey);const engineering={BlueprintName:known.blueprint,Level:known.grade,Quality:1,...known.experimental===void 0?{}:{ExperimentalEffect:known.experimental},...known.modifiers?.length?{Modifiers:getPreEngineeredJournalModifiers(known)}:{}};this.#replaceModule(module.Slot,{...module,Engineering:engineering},cloneModuleStats(stats),getPreEngineeredModifiers(known));return this}clearEngineering(slotKey){const module=this.#fittedModuleFor(slotKey);if(module&&this.#statsFor(module)?.engineeringLocked){throw new TypeError(`ShipLoadout.clearEngineering: module "${truncate(module.Item)}" is a final pre-engineered article and its engineering cannot be removed`)}if(module?.Engineering){const baseStats2=this.#engineeringBaseStats(module);const bare={Slot:module.Slot,Item:module.Item};if(module.On!==void 0)bare.On=module.On;if(module.Priority!==void 0){bare.Priority=module.Priority}if(module.Health!==void 0)bare.Health=module.Health;if(module.Value!==void 0)bare.Value=module.Value;this.#replaceModule(module.Slot,bare,baseStats2??void 0)}return this}setModuleEnabled(slotKey,on){this.#patchModule(slotKey,{On:on});return this}setModulePriority(slotKey,priority){if(!Number.isInteger(priority)||priority<0||priority>4){throw new RangeError(`ShipLoadout: power priority must be an integer 0-4, got ${truncate(priority)}`)}this.#patchModule(slotKey,{Priority:priority});return this}#patchModule(slotKey,patch){const module=this.#fittedModuleFor(slotKey);if(!module){throw new RangeError(`ShipLoadout: slot "${truncate(slotKey)}" is empty`)}this.#modules.set(module.Slot,cloneLoadoutModule({...module,...patch}));this.#slotCache.clear()}toLoadoutEvent(options={}){const unladenMass=this.#computedUnladenMass().value;const cargoCapacity=this.#computedCargoCapacity().value;const fuel=this.#computedFuelCapacity().value;const maxJumpRange=this.#exportableJumpRange(unladenMass);return exportLoadoutEvent({shipSymbol:this.#shipSymbol,...this.#top.ShipName===void 0?{}:{shipName:this.#top.ShipName},...this.#top.ShipIdent===void 0?{}:{shipIdent:this.#top.ShipIdent},modules:this.#modules,layout:this.#layout(),sourcePurchase:this.#sourcePurchase,retailHullValue:this.#ship.hullCost,unladenMass:unladenMass,cargoCapacity:cargoCapacity,fuelCapacity:fuel,maxJumpRange:maxJumpRange,statsFor:module=>this.#statsFor(module)},options)}toSlef(options){return toSlef(this.toLoadoutEvent(options),options.header)}toSlefString(options){return stringifySlef(this.toSlef(options),{indent:options.indent??0})}#exportableJumpRange(unladenMass){if(unladenMass===null)return null;let drive;try{drive=this.#resolveDrive()}catch{return null}if(drive===null)return null;const tank=this.#computedFuelCapacity().value;if(tank===null)return null;return singleJumpRange(unladenMass,Math.min(tank.main,drive.maxFuel),drive)}get frameShiftDrive(){const drive=this.#resolveDrive();if(drive===null)throw new TypeError("ShipLoadout: build has no frame shift drive");return drive}#maxJumpFuel(fsd){return Math.min(this.#requireFuelCapacity().main,fsd.maxFuel)}frameShiftDriveMassFactor(options={}){requireLoadOptions("ShipLoadout.frameShiftDriveMassFactor",options);const fuel=options.fuel??this.#requireFuelCapacity().main;return frameShiftDriveMassFactor(this.#requireMass(options.cargo??0),fuel,this.frameShiftDrive)}maxJumpRange(){const fsd=this.frameShiftDrive;return singleJumpRange(this.#requireMass(0),this.#maxJumpFuel(fsd),fsd)}jumpRange(options={}){requireLoadOptions("ShipLoadout.jumpRange",options);const fsd=this.frameShiftDrive;const fuel=options.fuel??this.#requireFuelCapacity().main;return singleJumpRange(this.#requireMass(options.cargo??0),fuel,fsd)}ladenJumpRange(){return this.jumpRange({cargo:this.#requireCargoCapacity()})}fuelPerJump(distance,options={}){requireLoadOptions("ShipLoadout.fuelPerJump",options);const fsd=this.frameShiftDrive;const fuel=options.fuel??this.#requireFuelCapacity().main;return fuelPerJump(distance,this.#requireMass(options.cargo??0),fuel,fsd)}totalRange(options={}){requireLoadOptions("ShipLoadout.totalRange",options);return totalRange(this.#requireMass(options.cargo??0),options.fuel??this.#requireFuelCapacity().main,this.frameShiftDrive)}standardLoadResult(load){if(load!=="maximum"&&load!=="unladen"&&load!=="laden"){throw new RangeError("ShipLoadout.standardLoadResult: load must be 'maximum', 'unladen', or 'laden'")}const fuel=this.fuelCapacityResult;const cargo=load==="laden"?this.cargoCapacityResult:completeResult(0);const mass=load==="maximum"?this.unladenMassResult:completeResult(0);const issues=[...fuel.issues,...cargo.issues,...mass.issues];let drive=null;let maximumFuel=null;if(load==="maximum"){const fitted=this.#frameShiftDriveModule();let driveError=null;try{drive=this.#resolveDrive();maximumFuel=drive?.maxFuel??null}catch(error){if(!(error instanceof Error))throw error;driveError=error}if(maximumFuel===null){issues.push({field:"frameShiftDrive",reason:fitted?"unresolved":"missing",slot:fitted?.Slot??"FrameShiftDrive",...fitted?{symbol:fitted.Item}:{},message:driveError?.message??"FrameShiftDrive: no frame shift drive is fitted",params:fitted?{field:"frameShiftDrive",reason:"unresolved",slot:fitted.Slot,symbol:fitted.Item}:{field:"frameShiftDrive",reason:"missing",slot:"FrameShiftDrive"}})}}if(issues.length>0){return incompleteResult(issues)}const value=Object.freeze({fuel:load==="maximum"?Math.min(fuel.value.main,maximumFuel):fuel.value.main,cargo:cargo.value});if(load==="maximum"){try{this.jumpRange(value)}catch(error){if(!(error instanceof RangeError))throw error;const fitted=this.#frameShiftDriveModule();const field=drive!==null&&(!Number.isFinite(drive.maxFuel)||drive.maxFuel<0)?"frameShiftDrive":!Number.isFinite(value.fuel)||value.fuel<0?"fuelCapacity":!Number.isFinite(mass.value)||mass.value<0?"mass":"frameShiftDrive";const driveParams=field==="frameShiftDrive"&&fitted?{slot:fitted.Slot,symbol:fitted.Item}:{};return incompleteResult([{field:field,reason:"invalid",...driveParams,message:error.message,params:{field:field,reason:"invalid",...driveParams}}])}}return completeResult(value)}jumpRangeSummary(){const maximum=this.#require(this.standardLoadResult("maximum"),"maximum load");const unladen=this.#require(this.standardLoadResult("unladen"),"unladen load");const laden=this.#require(this.standardLoadResult("laden"),"laden load");return{max:this.jumpRange(maximum),unladen:this.jumpRange(unladen),laden:this.jumpRange(laden),totalMax:this.totalRange(maximum),totalUnladen:this.totalRange(unladen),totalLaden:this.totalRange(laden)}}powerBudget(){const modules=[...this.#modules.values()];const consumers=[];for(const module of modules){const consumer=powerConsumerFor(module,this.#statsFor(module));if(consumer)consumers.push(consumer)}return powerBudget(powerAvailable(modules,module=>this.#statsFor(module)),consumers)}heatMetrics(){const input=heatInputFor(this.#ship,this.#modulesForEffectiveStats(),this.powerBudget(),module=>this.#statsFor(module));return input?heatMetrics(input):null}mobilityMetrics(options={}){requireEnginesPips("ShipLoadout.mobilityMetrics",options.enginesPips??4);requireLoadOptions("ShipLoadout.mobilityMetrics",options);return this.mobilityMetricsResult(options).value}mobilityMetricsResult(options={}){const enginesPips=requireEnginesPips("ShipLoadout.mobilityMetricsResult",options.enginesPips??4);requireLoadOptions("ShipLoadout.mobilityMetricsResult",options);const input=mobilityInputResultFor(this.#ship,[...this.#modules.values()],()=>this.powerBudget(),()=>{const main=options.fuel??this.#top.FuelCapacity?.Main??this.#requireFuelCapacity().main;return this.#requireMass(options.cargo??0)+main},enginesPips,module=>this.#statsFor(module));if(!input.complete)return input;return completeResult(mobilityMetrics(input.value))}shieldMetrics(options={}){requireSystemsPips("ShipLoadout.shieldMetrics",options.systemsPips??0);return this.shieldMetricsResult(options).value}shieldMetricsResult(options={}){const systemsPips=requireSystemsPips("ShipLoadout.shieldMetricsResult",options.systemsPips??0);const input=shieldInputResultFor(this.#ship,[...this.#modules.values()],()=>this.powerBudget(),systemsPips,module=>this.#statsFor(module));if(!input.complete)return input;return completeResult(shieldMetrics(input.value))}shieldRecovery(options={}){requireSystemsPips("ShipLoadout.shieldRecovery",options.systemsPips??4);return this.shieldRecoveryResult(options).value}shieldRecoveryResult(options={}){const systemsPips=requireSystemsPips("ShipLoadout.shieldRecoveryResult",options.systemsPips??4);const input=shieldRecoveryInputResultFor(this.#ship,[...this.#modules.values()],()=>this.powerBudget(),systemsPips,module=>this.#statsFor(module));if(!input.complete)return input;return completeResult(shieldRecovery(input.value))}cellBanks(){const modules=[...this.#modules.values()];const banks=orderBySlotLayout(cellBankInputsFor(modules,this.powerBudget(),module=>this.#statsFor(module)),this.#layout(),bank=>bank.slot);return cellBankSummary(banks)}retailCredits(){const hull=this.#ship.hullCost;let modules=0;const unpriced=[];for(const module of this.#modules.values()){const stats=this.#statsFor(module);if(stats?.cost!==void 0){modules+=stats.cost}else if(stats!==null||!isNonOutfittingSlot(module.Slot)&&!isBuiltInHullModule(module)){unpriced.push({slot:module.Slot,symbol:module.Item})}}return deepFreeze({hull:hull,modules:modules,rebuy:Math.trunc((hull+modules)*.05),unpriced:unpriced})}mercCoinCost(){let total=0;for(const slotKey of this.#modules.keys()){total+=this.fittedModuleAt(slotKey)?.preEngineeredVariant?.mercCoinCost??0}return total}armourMetrics(){return armourMetrics(armourInputFor(this.#ship,[...this.#modules.values()],module=>this.#statsFor(module)))}weaponMetrics(){const weapons=[];for(const module of this.#modules.values()){const record=this.#statsFor(module);const stats=weaponStatsFor(this.#moduleForEffectiveStats(module),record);if(!stats)continue;weapons.push({slot:module.Slot,symbol:module.Item,name:record?.name??module.Item,enabled:module.On!==false,metrics:weaponMetrics(stats),ammunition:ammunitionCapacity(stats),...stats.maximumRange===void 0?{}:{maximumRange:stats.maximumRange},...stats.falloffRange===void 0?{}:{falloffRange:stats.falloffRange},...stats.projectileRange===void 0?{}:{projectileRange:{...stats.projectileRange}},...stats.armourPiercing===void 0?{}:{armourPiercing:stats.armourPiercing}})}const orderedWeapons=orderBySlotLayout(weapons,this.#layout(),weapon=>weapon.slot);return{weapons:orderedWeapons,total:sumWeaponMetrics(orderedWeapons.filter(weapon=>weapon.enabled).map(weapon=>weapon.metrics))}}weaponsCapacitorMetrics(options={}){const weaponsPips=options.weaponsPips??4;if(!Number.isFinite(weaponsPips)||weaponsPips<0||weaponsPips>4){throw new RangeError("ShipLoadout.weaponsCapacitorMetrics: weaponsPips must be a finite number from 0 to 4")}return weaponsCapacitorMetrics(weaponsCapacitorInputFor(this.#modulesForEffectiveStats(),weaponsPips,this.powerBudget(),module=>this.#statsFor(module)))}distributorMetrics(options={}){const pips={systemsPips:options.systemsPips??4,enginesPips:options.enginesPips??4,weaponsPips:options.weaponsPips??4};for(const field of["systemsPips","enginesPips","weaponsPips"]){const value=pips[field];if(!Number.isFinite(value)||value<0||value>4){throw new RangeError(`ShipLoadout.distributorMetrics: ${field} must be a finite number from 0 to 4`)}}const input=distributorInputFor(this.#modulesForEffectiveStats(),pips,this.powerBudget(),module=>this.#statsFor(module));return input?distributorMetrics(input):null}#layout(){if(this.#layoutCache===void 0){this.#layoutCache=Object.freeze(enumerateSlots(this.#ship))}return this.#layoutCache}#requireSlot(slotKey){const wanted=requireString(slotKey,SLOT_KEY).toLowerCase();const slot=this.#layout().find(s=>s.key.toLowerCase()===wanted);if(!slot){throw new RangeError(`ShipLoadout: hull "${truncate(this.#shipSymbol)}" has no slot "${truncate(slotKey)}"`)}return slot}#fittedKey(slotKey){return matchingKeyIn(this.#modules,requireString(slotKey,SLOT_KEY))}#fittedModuleFor(slotKey){const key=this.#fittedKey(slotKey);return key===null?void 0:this.#modules.get(key)}#require(result,what){if(result.value===null){throw new TypeError(`ShipLoadout: cannot determine ${what} (${result.issues.map(i=>i.message).join("; ")})`)}return result.value}#requireMass(cargo){return this.#require(this.unladenMassResult,"mass")+cargo}#requireFuelCapacity(){return this.#require(this.fuelCapacityResult,"fuel capacity")}#requireCargoCapacity(){return this.#require(this.cargoCapacityResult,"cargo capacity")}#calculationModules(){return[...this.#modules.values()].map(module=>{const stats=this.#statsFor(module);const symbol=module.Item.toLowerCase();const parsedSlot=parseSlotName(module.Slot);const unresolvedOutfitting=stats===null&&!isNonOutfittingSlot(module.Slot)&&!isBuiltInHullModule(module);const isCargoRack=stats?.cargoCapacity!==void 0||symbol.includes("cargorack");const isFuelTank=stats?.fuelCapacity!==void 0||stats?.slot==="fuelTank"||symbol.startsWith(FUEL_TANK_PREFIX);const mayCarryCapacity=unresolvedOutfitting&&(parsedSlot===null||parsedSlot.kind==="optional");const mayCarryFuel=mayCarryCapacity||unresolvedOutfitting&&parsedSlot?.kind==="core"&&parsedSlot.core==="fuelTank";return{slot:module.Slot,symbol:module.Item,mass:this.#moduleMass(module),...isCargoRack||mayCarryCapacity?{cargoCapacity:isCargoRack?this.#moduleCapacity(module,"CargoCapacity","cargoCapacity"):null}:{},...isFuelTank||mayCarryFuel?{fuelCapacity:isFuelTank?this.#moduleCapacity(module,"FuelCapacity","fuelCapacity"):null}:{}}})}#moduleLimits(){const entries=[...this.#modules.values()].flatMap(module=>{const stats=this.#statsFor(module);return stats===null?[]:[stats]});return calculateModuleLimits(entries)}#moduleStatsAt(slotKey){const fitted=this.#fittedModuleFor(slotKey);return fitted===void 0?null:this.#statsFor(fitted)}#engineeringBaseStats(module){const fitted=this.#statsFor(module);if(!module.Engineering||identifyPreEngineeredVariant(module)===null)return fitted;const stock=builtInModuleBySymbol(module.Item,FITTED_ITEM);if(!stock)return fitted;return fitted?.engineeringLocked?cloneModuleStats({...stock,engineeringLocked:true}):stock}#moduleForEffectiveStats(module){const modifiers=this.#primitiveModifiers.get(module.Slot);if(modifiers===void 0||module.Engineering===void 0)return module;return{...module,Engineering:{...module.Engineering,Modifiers:modifiers}}}#modulesForEffectiveStats(){return[...this.#modules.values()].map(module=>this.#moduleForEffectiveStats(module))}#moduleLimitRegression(slotKey,replacement,current=this.#moduleLimits(),previous=this.#moduleStatsAt(slotKey)){if(previous?.limitGroup===void 0&&previous?.limitIncrease===void 0&&replacement?.limitGroup===void 0&&replacement?.limitIncrease===void 0){return null}for(const usage of current){const count=usage.count-Number(previous?.limitGroup===usage.group)+Number(replacement?.limitGroup===usage.group);const increase=usage.increase-(previous?.limitIncrease?.group===usage.group?previous.limitIncrease.amount:0)+(replacement?.limitIncrease?.group===usage.group?replacement.limitIncrease.amount:0);const limit=usage.baseLimit+increase;const excess=Math.max(0,count-limit);if(excess>usage.excess){return{...usage,increase:increase,limit:limit,count:count,excess:excess}}}return null}#replaceModule(slotKey,replacement,replacementStats,primitiveModifiers){const previous=this.#modules.get(slotKey)??null;this.#adjustImportedFigures(previous,replacement,replacementStats);if(replacement===null){this.#modules.delete(slotKey);this.#moduleStats.delete(slotKey);this.#primitiveModifiers.delete(slotKey)}else{this.#modules.set(slotKey,cloneLoadoutModule(replacement));if(replacementStats!==void 0)this.#moduleStats.set(slotKey,replacementStats);if(primitiveModifiers===void 0)this.#primitiveModifiers.delete(slotKey);else this.#primitiveModifiers.set(slotKey,primitiveModifiers)}this.#slotCache.clear()}#adjustImportedFigures(previous,next,nextStats){const previousMass=this.#moduleMass(previous);const nextMass=this.#moduleMass(next,nextStats);if(this.#top.UnladenMass!==void 0){if(previousMass===null||nextMass===null)delete this.#top.UnladenMass;else this.#top.UnladenMass+=nextMass-previousMass}const previousCargo=this.#moduleCapacity(previous,"CargoCapacity","cargoCapacity");const nextCargo=this.#moduleCapacity(next,"CargoCapacity","cargoCapacity",nextStats);if(this.#top.CargoCapacity!==void 0){if(previousCargo===null||nextCargo===null)delete this.#top.CargoCapacity;else this.#top.CargoCapacity+=nextCargo-previousCargo}const previousFuel=this.#moduleCapacity(previous,"FuelCapacity","fuelCapacity");const nextFuel=this.#moduleCapacity(next,"FuelCapacity","fuelCapacity",nextStats);if(this.#top.FuelCapacity?.Main!==void 0){const reserve=this.#top.FuelCapacity.Reserve;if(previousFuel===null||nextFuel===null){if(reserve===void 0)delete this.#top.FuelCapacity;else this.#top.FuelCapacity={Reserve:reserve}}else{this.#top.FuelCapacity={Main:this.#top.FuelCapacity.Main+nextFuel-previousFuel,...reserve===void 0?{}:{Reserve:reserve}}}}if(normalizeKey(previous?.Item,FITTED_ITEM)===normalizeKey(next?.Item,FITTED_ITEM)){return}if(previous!==null&&isCargoHatchSlot(previous.Slot)||next!==null&&isCargoHatchSlot(next.Slot)){return}delete this.#top.ModulesValue;delete this.#top.Rebuy}#moduleMass(module,statsOverride){if(module===null)return 0;if(isCargoHatchSlot(module.Slot))return 0;const modified=getLoadoutModifier(module,"Mass");if(modified!==null)return modified;const stats=statsOverride??this.#statsFor(module);if(stats?.mass!==void 0)return stats.mass;return stats===null&&isNonOutfittingSlot(module.Slot)?0:null}#moduleCapacity(module,modifierLabel,field,statsOverride){if(module===null)return 0;if(isCargoHatchSlot(module.Slot))return 0;const modified=getLoadoutModifier(module,modifierLabel);if(modified!==null)return modified;const stats=statsOverride??this.#statsFor(module);if(stats?.[field]!==void 0)return stats[field];const symbol=module.Item.toLowerCase();const isFuelTank=stats?.slot?stats.slot==="fuelTank":symbol.startsWith(FUEL_TANK_PREFIX);const shouldCarryCapacity=field==="cargoCapacity"?symbol.includes("cargorack"):isFuelTank;return shouldCarryCapacity?null:0}#frameShiftDriveModule(){for(const m of this.#modules.values()){const stats=this.#statsFor(m);const isDrive=stats?.slot?stats.slot==="frameShiftDrive":m.Item.toLowerCase().startsWith(FSD_PREFIX);if(isDrive){return m}}return void 0}#resolveDrive(){const fsdModule=this.#frameShiftDriveModule();if(!fsdModule)return null;const base=this.#statsFor(fsdModule);if(!base||base.fuelMul===void 0||base.fuelPower===void 0){throw new TypeError(`ShipLoadout: no jump constants in the stats catalogue for frame shift drive "${truncate(fsdModule.Item)}"`)}const optMass=getLoadoutModifier(fsdModule,"FSDOptimalMass")??base.optMass;const maxFuel=getLoadoutModifier(fsdModule,"MaxFuelPerJump")??base.maxFuel;if(optMass===void 0||maxFuel===void 0){const missing=[...optMass===void 0?["optMass"]:[],...maxFuel===void 0?["maxFuel"]:[]];throw new TypeError(`ShipLoadout: frame shift drive "${truncate(fsdModule.Item)}" has no ${missing.join(" or ")} in the stats catalogue`)}return{optMass:optMass,maxFuel:maxFuel,fuelMul:base.fuelMul,fuelPower:base.fuelPower,jumpBoost:this.#resolveJumpBoost()}}#resolveJumpBoost(){for(const m of this.#modules.values()){const stats=this.#statsFor(m);if(stats?.engineeringGroup!=="fsdBoosters"&&!m.Item.toLowerCase().startsWith(BOOSTER_PREFIX)){continue}if(m.On===false)continue;if(stats?.jumpBoost===void 0){throw new TypeError(`ShipLoadout: FSD booster "${truncate(m.Item)}" has no jumpBoost in the stats catalogue`)}return stats.jumpBoost}return 0}#statsFor(module){if(module===null)return null;const stats=this.#moduleStats.get(module.Slot)??builtInModuleBySymbol(module.Item,FITTED_ITEM);if(stats)return stats;return isBuiltInHullModule(module)?builtInModuleBySymbol("ModularCargoBayDoor","ShipLoadout: built-in module"):null}};export{LoadoutEditError,ShipLoadout};//# sourceMappingURL=chunk-VSNS7Y3M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ships/internal/loadout-metrics.ts","../src/ships/internal/loadout-fitting.ts","../src/ships/internal/loadout-export.ts","../src/ships/internal/loadout-import.ts","../src/ships/ship-loadout.ts"],"names":["shieldMetrics","getShipBySymbol","getShipByName","parseSlef","toSlef","stringifySlef","getLoadoutModifier","sourcePurchaseFromLoadout","getSourceModuleValue","weaponsCapacitorMetrics","powerBudget","isCargoHatchSlot","matchingKeyIn","ownKeyIn","isBuiltInHullModule","isNonOutfittingSlot","cloneLoadoutModule","identifyPreEngineeredVariant","cloneModuleStats","availableBlueprintsFor","availableExperimentalsFor","blueprintAvailableFor","blueprintRoutesFor","experimentalAvailableFor","primitiveEngineeringInputsFor","missingBaseLabels","journalModifiersFor","getPreEngineeredStats","getPreEngineeredJournalModifiers","getPreEngineeredModifiers","ordinaryEngineeringProof","unresolvedModifiers","orderBySlotLayout","FITTED_ITEM","isFinalGuardianWeaponEngineering","scaleDamageComponents","weaponMetrics","sumWeaponMetrics","combinedRateOfFire","builtInModuleBySymbol","getBulkheadsForShip","getPreEngineeredVariants","shieldRecovery","cellBankSummary","completeResult","calculateUnladenMass","calculateCargoCapacity","calculateFuelCapacity","incompleteResult","validateLoadout","fixedSlotReason","mobilityMetrics","calculateModuleLimits","ALL_MODULES","CORE_MODULES","getExperimentalEffect","heatMetrics","singleJumpRange","frameShiftDriveMassFactor","fuelPerJump","totalRange","ammunitionCapacity","armourMetrics","baseStats","computeModifiers","labelsForDamageType","scaleForLabel","fieldForLabel","labelsForField","capabilityValueForLabel","damageTypeForLabel","resolveBlueprintForModule","getExperimentalsForModule","getBlueprintGrade","getDefaultLoadout","distributorMetrics","loadoutSlotName","parseSlotName","enumerateSlots","SLOT_RESTRICTION_LABELS","normalizeKey","truncate","describeValue","requireString","requireStringIfPresent","deepFreeze","PREFIX","powerPlant","thrusters","frameShiftDrive","powerDistributor","shieldGenerator","shieldCellBank","shieldBooster","shieldReinforcement","hullReinforcement","moduleReinforcement","startsWithAny","symbol","prefixes","some","prefix","toLowerCase","startsWith","isPowerDistributor","module","stats","slot","Item","isPowerPlant","parsed","Slot","kind","core","isThruster","isFrameShiftDrive","isEnabled","On","priorityOf","Priority","effectiveStat","field","stated","statedModifier","base","label","modified","effectiveCapability","Engineering","Modifiers","modifier","Label","effectiveDamageDistribution","fromEffect","ExperimentalEffect","damageDistribution","distribution","resolved","seen","Set","type","has","add","Value","convertsDamage","modifierRatio","effective","relatedStat","ratio","effectiveModule","merged","fields","Object","keys","key","capability","value","engineeringGroup","massRatio","minMass","maxMass","performanceRatio","minMultiplier","maxMultiplier","category","normalizeEffectiveWeapon","damageComponents","damage","powerConsumerFor","draw","parsedSlot","mounted","deployedOnly","alwaysPowered","common","priority","enabled","inherentlyPassiveSlot","drawUnknown","powerAvailable","modules","statsFor","metricIssue","reason","defaultSlot","params","message","unavailable","powerPlantIssueFor","capacity","Number","isFinite","powerDrawIssueFor","consumer","poweredMetricBudgetFor","getBudget","plantIssue","drawIssue","budget","available","poweredStates","retracted","poweredShieldGeneratorResultFor","powered","complete","mapResistanceFields","read","kineticResistance","thermalResistance","explosiveResistance","causticResistance","resistancesOf","shieldInputFor","ship","systemsPips","generator","boosters","reinforcement","strengthRatio","optMass","Math","max","optMultiplier","push","shieldBoost","hullMass","baseShieldStrength","shieldInputResultFor","fitted","input","mobilityInputResultFor","mass","enginesPips","optSpeedMultiplier","speedCurve","minSpeedMultiplier","maxSpeedMultiplier","optRotationMultiplier","rotationCurve","minRotationMultiplier","maxRotationMultiplier","minimumSpeed","maximumSpeed","boost","minPitch","pitch","minRoll","roll","minYaw","yaw","shieldRecoveryInputResultFor","generatorModule","distributor","generatorStats","distributorStats","strength","regenRate","brokenRegenRate","distributorDraw","systemsCapacity","systemsRecharge","weaponsCapacitorInputFor","weaponsPips","weaponsCapacity","weaponsRecharge","sustainedEnergyPerSecond","deployed","weapon","weaponStatsFor","distributorInputFor","pips","enginesCapacity","enginesRecharge","heatInputFor","heatEfficiency","thrusterHeatRate","deployedThrusterHeatRate","fsdHeatRate","weapons","unknownWeaponHeat","running","heat","heatPerSecond","sustainedHeatPerSecond","heatCapacity","heatDissipation","retractedPowerDraw","poweredDraw","deployedPowerDraw","unknownDraws","map","state","bands","reduce","total","band","min","length","poweredRetracted","poweredDeployed","cellBankInputsFor","banks","ammunition","reinforcementRate","shieldBankReinforcement","cells","spinUp","shieldBankSpinUp","duration","shieldBankDuration","shieldBankHeat","stockBulkhead","variants","name","find","v","endsWith","armourInputFor","reinforcements","moduleReinforcements","bulkhead","hullBoost","moduleProtection","integrity","stock","baseArmour","WEAPON_FIELDS","projectileRange","burstAdjustedRateOfFire","touched","rate","rateOfFire","statedDamagePerSecond","firingFactor","roundsPerShot","maximumRange","falloffRange","MILITARY_PREFIXES","MINING_PREFIXES","CARGO_PREFIXES","RESTRICTED_SLOT_PREFIXES","mining","military","cargo","limpetController","vesselHangar","passenger","planetaryApproachSuite","problem","constraint","restrictionProblem","restriction","moduleSlotProblem","required","restrictedToSlot","moduleFitProblem","shipSymbol","hull","armourHull","armourShipName","armourShipSymbol","shipName","restricted","restrictedToShips","allowedShipNames","labels","index","join","allowedShipSymbols","wrongMount","moduleSlot","requiredCore","isFuelTank","class","size","moduleClass","slotSize","moduleFitError","REBUY_FRACTION","exportLoadoutEvent","options","fromSource","credits","source","sourcePurchase","totals","sourceTotalsHold","hullValue","retailHullValue","modulesValue","computedModulesValue","rebuy","trunc","event","Ship","ShipName","shipIdent","ShipIdent","HullValue","ModulesValue","unladenMass","UnladenMass","cargoCapacity","CargoCapacity","maxJumpRange","MaxJumpRange","fuelCapacity","FuelCapacity","Main","main","Reserve","reserve","Rebuy","Modules","exportModules","ordered","moduleOrder","slotOrderedModules","layout","values","on","explicitPower","sourceModuleValue","moduleValue","Health","sum","cost","SOURCE_ITEM","entry","item","moduleValues","get","captureLoadoutEvent","Array","isArray","captureEach","captureModule","capture","captured","health","engineering","captureEngineering","experimental","experimentalLocalised","ExperimentalEffect_Localised","modifiers","BlueprintName","Level","Quality","normalizeLoadoutEvent","rawEvent","TypeError","Map","slots","entries","normalizedSlot","set","top","moduleStats","primitiveModifiers","variant","catalogueVariantStats","variantStats","retainsBakedExperimental","trim","engineeringLocked","originalExperimental","withoutExperimental","currentExperimental","currentVariant","guardianFinal","normalizedBlueprint","normalizedExperimental","exact","candidate","blueprint","grade","guardianBase","SLOT_KEY","requireLoadOptions","scope","RangeError","requireEnginesPips","requireSystemsPips","LoadoutEditError","code","constructor","super","this","structuredClone","experimentalEffectUnsupported","engineeringNormalizationUnsupported","FSD_PREFIX","BOOSTER_PREFIX","FUEL_TANK_PREFIX","ShipLoadout","_ShipLoadout","slotCache","layoutCache","fromSlef","imported","data","fromImported","fromLoadout","defaultHatch","capturedHatchKey","capturedHatch","ownSlot","build","repairFixedMount","empty","requested","hatch","loadout","unladenMassResult","computedUnladenMass","calculationModules","fuelCapacityResult","cap","freeze","computed","computedFuelCapacity","cargoCapacityResult","computedCargoCapacity","reserveFuelCapacity","validation","byKey","builtIn","fitProblem","known","requiresKnownSlot","fitError","fitConstraint","fitParams","exclusionGroup","limitGroup","limitIncrease","cached","filter","currentLimits","moduleLimits","moduleStatsAt","fixedReason","immovableReason","moduleLimitRegression","fittedModuleAt","removable","slotKey","fittedModuleFor","raw","moduleForEffectiveStats","effectiveStats","preEngineeredVariant","fittedModules","flatMap","availableBlueprints","availableExperimentalEffects","modulesForSlot","requireSlot","occupied","group","currentStats","wanted","fittedKey","resultSlot","canonicalKey","status","current","valid","defaultModule","ownKey","replacement","replacementStats","replaceModule","setModule","conflict","previousSlot","previousSymbol","limitProblem","count","limit","removeModule","applyBlueprint","fdname","wantedGrade","wantedQuality","quality","wantedExperimental","fittedStats","recipe","named","written","acquisition","isInteger","offered","route","engineeringBaseStats","canonical","missing","features","damageModifier","OriginalValue","setExperimentalEffect","previous","effect","restoresBakedEffect","originalEffect","withoutEffect","adjusted","currentEffect","blueprintGrade","previousExperimental","completeEngineeringGrade","previousQuality","proof","setPreEngineeredVariant","unresolved","clearEngineering","bare","setModuleEnabled","patchModule","setModulePriority","patch","clear","toLoadoutEvent","fuel","exportableJumpRange","hullCost","header","toSlefString","indent","drive","resolveDrive","tank","maxFuel","maxJumpFuel","fsd","requireFuelCapacity","requireMass","jumpRange","ladenJumpRange","requireCargoCapacity","distance","standardLoadResult","load","issues","maximumFuel","frameShiftDriveModule","driveError","error","Error","driveParams","jumpRangeSummary","maximum","require","unladen","laden","totalMax","totalUnladen","totalLaden","consumers","modulesForEffectiveStats","mobilityMetricsResult","shieldMetricsResult","shieldRecoveryResult","cellBanks","bank","retailCredits","unpriced","mercCoinCost","record","metrics","armourPiercing","orderedWeapons","s","result","what","i","unresolvedOutfitting","isCargoRack","includes","mayCarryCapacity","mayCarryFuel","moduleMass","moduleCapacity","usage","increase","amount","baseLimit","excess","adjustImportedFigures","delete","next","nextStats","previousMass","nextMass","previousCargo","nextCargo","previousFuel","nextFuel","statsOverride","modifierLabel","shouldCarryCapacity","m","isDrive","fsdModule","fuelMul","fuelPower","jumpBoost","resolveJumpBoost"],"mappings":"O,wmFAwEA,IAAMsF,OAAS,CACXC,WAAY,CAAC,iBAAkB,0BAC/BC,UAAW,CAAC,aAAc,6BAC1BC,gBAAiB,CAAC,kBAClBC,iBAAkB,CAAC,uBAAwB,gCAC3CC,gBAAiB,CAAC,uBAClBC,eAAgB,CAAC,sBACjBC,cAAe,CAAC,qBAChBC,oBAAqB,CAAC,mCACtBC,kBAAmB,CACf,wBACA,gCACA,kCAEJC,oBAAqB,CAAC,0BAA2B,oCAGrD,IAAMC,cAAgB,CAACC,OAAgBC,WACnCA,SAASC,KAAMC,QAAWH,OAAOI,cAAcC,WAAWF,SAG9D,SAASG,mBAAmBC,OAAuBC,OAC/C,OAAOA,OAAOC,KACRD,MAAMC,OAAS,mBACfV,cAAcQ,OAAOG,KAAMtB,OAAOI,iBAC5C,CAGA,SAASmB,aAAaJ,OAAuBC,OACzC,MAAMI,OAASjC,cAAc4B,OAAOM,MACpC,GAAID,QAAQE,OAAS,QAAUF,OAAOG,OAAS,aAAc,OAAO,KACpE,OAAOP,OAAOC,KACRD,MAAMC,OAAS,aACfV,cAAcQ,OAAOG,KAAMtB,OAAOC,WAC5C,CAGA,SAAS2B,WAAWT,OAAuBC,OACvC,MAAMI,OAASjC,cAAc4B,OAAOM,MACpC,GAAID,QAAQE,OAAS,QAAUF,OAAOG,OAAS,YAAa,OAAO,KACnE,OAAOP,OAA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AmClX,SAASgnB,UAAUrlB,iBAAiB0e,QAAQvO,KAAK,iCAE5F,CAEA,MAAO,CACHpJ,gBACA+Z,gBACAwE,QAAStkB,KAAKskB,QACdC,UAAWvkB,KAAKukB,UAChBC,UAAW5N,MAAK6N,mBAExB,CAGA,iBAAAA,GACI,IAAA,MAAWN,KAAKvN,MAAKpT,QAAS+O,SAAU,CACpC,MAAMzT,MAAQ8X,MAAKnT,SAAU0gB,GAC7B,GACIrlB,OAAOmD,mBAAqB,gBAC3BkiB,EAAEnlB,KAAKN,cAAcC,WAAWsY,gBACnC,CACE,QACJ,CACA,GAAIkN,EAAE1kB,KAAO,MAAO,SACpB,GAAIX,OAAO0lB,iBAAc,EAAW,CAChC,MAAM,IAAIjQ,UACN,6BAA6BlX,SAAS8mB,EAAEnlB,iDAEhD,CACA,OAAOF,MAAM0lB,SACjB,CACA,OAAO,CACX,CAGA,SAAA/gB,CAAU5E,QACN,GAAIA,SAAW,KAAM,OAAO,KAC5B,MAAMC,MACF8X,MAAK9B,YAAa3B,IAAItU,OAAOM,OAASxE,sBAAsBkE,OAAOG,KAAM3E,aAC7E,GAAIyE,MAAO,OAAOA,MAIlB,OAAO5F,oBAAoB2F,QACrBlE,sBAAsB,sBAAuB,gCAC7C,IACV,UACJ6b,iBAAAW"}
@@ -1 +1 @@
1
- var OVERHEAT_HEAT_LEVEL=1.5;var DRAINED_CAPACITOR_MULTIPLIER=5;function equilibriumHeatLevel(dissipation,thermalLoad){requireNonNegative("equilibriumHeatLevel","dissipation",dissipation);requireNonNegative("equilibriumHeatLevel","thermal load",thermalLoad);if(dissipation===0)return thermalLoad===0?0:Infinity;return Math.sqrt(thermalLoad/dissipation)}function effectiveWeaponThermalLoad(thermalLoad,distributorDraw,weaponsCapacity,capacitorLevel){requireNonNegative("effectiveWeaponThermalLoad","thermal load",thermalLoad);requireNonNegative("effectiveWeaponThermalLoad","distributor draw",distributorDraw);requireNonNegative("effectiveWeaponThermalLoad","weapons capacity",weaponsCapacity);requireNonNegative("effectiveWeaponThermalLoad","capacitor level",capacitorLevel);if(capacitorLevel>1){throw new RangeError("effectiveWeaponThermalLoad: capacitor level must be at most 1")}if(weaponsCapacity===0){return thermalLoad*(distributorDraw>0?DRAINED_CAPACITOR_MULTIPLIER:1)}const shortfall=clamp(1-(weaponsCapacity*capacitorLevel-distributorDraw)/weaponsCapacity);return thermalLoad*(1+(DRAINED_CAPACITOR_MULTIPLIER-1)*shortfall)}function heatLevelAtTime(params){const{heatCapacity:heatCapacity,heatDissipation:heatDissipation,thermalLoad:thermalLoad,startLevel:startLevel,seconds:seconds}=params;validateHeatParams("heatLevelAtTime",heatCapacity,heatDissipation,thermalLoad,startLevel);requireNonNegative("heatLevelAtTime","seconds",seconds);if(seconds===0)return startLevel;const linearRate=(thermalLoad-heatDissipation)/heatCapacity;if(startLevel>=1){if(linearRate>=0)return startLevel+linearRate*seconds;const secondsToOne=(startLevel-1)/-linearRate;if(seconds<=secondsToOne)return startLevel+linearRate*seconds;return belowOneLevelAtTime(heatCapacity,heatDissipation,thermalLoad,1,seconds-secondsToOne)}if(thermalLoad>heatDissipation){const secondsToOne=belowOneSecondsToLevel(heatCapacity,heatDissipation,thermalLoad,startLevel,1);if(seconds>secondsToOne)return 1+linearRate*(seconds-secondsToOne)}return belowOneLevelAtTime(heatCapacity,heatDissipation,thermalLoad,startLevel,seconds)}function secondsToHeatLevel(params){const{heatCapacity:heatCapacity,heatDissipation:heatDissipation,thermalLoad:thermalLoad,startLevel:startLevel,targetLevel:targetLevel}=params;validateHeatParams("secondsToHeatLevel",heatCapacity,heatDissipation,thermalLoad,startLevel);requireNonNegative("secondsToHeatLevel","target level",targetLevel);if(targetLevel===startLevel)return 0;const linearRate=(thermalLoad-heatDissipation)/heatCapacity;if(targetLevel>startLevel){let seconds2=0;let level2=startLevel;if(level2<1){const to=Math.min(targetLevel,1);seconds2=belowOneSecondsToLevel(heatCapacity,heatDissipation,thermalLoad,level2,to);if(!Number.isFinite(seconds2)||targetLevel<=1)return seconds2;level2=1}if(linearRate<=0)return Infinity;return seconds2+(targetLevel-level2)/linearRate}let seconds=0;let level=startLevel;if(level>1){if(linearRate>=0)return Infinity;const to=Math.max(targetLevel,1);seconds=(level-to)/-linearRate;if(targetLevel>=1)return seconds;level=1}return seconds+belowOneSecondsToLevel(heatCapacity,heatDissipation,thermalLoad,level,targetLevel)}function heatMetrics(input){const{heatCapacity:heatCapacity,heatDissipation:heatDissipation,heatEfficiency:heatEfficiency}=input;requireNonNegative("heatMetrics","heat capacity",heatCapacity);requireNonNegative("heatMetrics","heat dissipation",heatDissipation);if(heatCapacity===0)throw new RangeError("heatMetrics: heat capacity must be above 0");requireNonNegative("heatMetrics","heat efficiency",heatEfficiency);const retracted=requireNonNegative("heatMetrics","retracted power draw",input.retractedPowerDraw??0);const deployed=requireNonNegative("heatMetrics","deployed power draw",input.deployedPowerDraw??retracted);const thrusterHeat=requireNonNegative("heatMetrics","thruster heat rate",input.thrusterHeatRate??0);const deployedThrusterHeat=requireNonNegative("heatMetrics","deployed thruster heat rate",input.deployedThrusterHeatRate??thrusterHeat);const fsdHeat=requireNonNegative("heatMetrics","FSD heat rate",input.fsdHeatRate??0);const weaponsCapacity=requireNonNegative("heatMetrics","weapons capacity",input.weaponsCapacity??0);const idleLoad=retracted*heatEfficiency;const deployedLoad=deployed*heatEfficiency;const weaponHeat=capacitorLevel=>(input.weapons??[]).reduce((total,weapon)=>total+effectiveWeaponThermalLoad(weapon.heatPerSecond??0,weapon.distributorDraw??0,weaponsCapacity,capacitorLevel),0);const firingBase=deployedLoad+deployedThrusterHeat;const state=(load,base)=>heatState(heatCapacity,heatDissipation,load,base);return{heatEfficiency:heatEfficiency,hullHeatCapacity:heatCapacity,hullHeatDissipation:heatDissipation,idle:state(idleLoad,0),thrusters:state(idleLoad+thrusterHeat,idleLoad),fsdCharging:state(idleLoad+thrusterHeat+fsdHeat,idleLoad+thrusterHeat),firingSustained:state(firingBase+weaponHeat(1),firingBase),firingDrained:state(firingBase+weaponHeat(0),firingBase),unknownDraws:[...input.unknownDraws??[]]}}function heatState(heatCapacity,heatDissipation,thermalLoad,baseLoad){const overheats=thermalLoad>heatDissipation;const heatLevel=overheats?Infinity:equilibriumHeatLevel(heatDissipation,thermalLoad);const baseLevel=baseLoad>heatDissipation?1:equilibriumHeatLevel(heatDissipation,baseLoad);return{thermalLoad:thermalLoad,heatLevel:heatLevel,gauge:heatLevel/OVERHEAT_HEAT_LEVEL,overheats:overheats,secondsToOverheat:overheats?secondsToHeatLevel({heatCapacity:heatCapacity,heatDissipation:heatDissipation,thermalLoad:thermalLoad,startLevel:baseLevel,targetLevel:OVERHEAT_HEAT_LEVEL}):null}}function belowOneLevelAtTime(heatCapacity,heatDissipation,thermalLoad,startLevel,seconds){const dissipationRate=heatDissipation/heatCapacity;if(heatDissipation===0)return startLevel+thermalLoad/heatCapacity*seconds;if(thermalLoad===0){if(startLevel===0)return 0;return 1/(1/startLevel+dissipationRate*seconds)}const loadRate=thermalLoad/heatCapacity;const settled=Math.sqrt(loadRate/dissipationRate);const rate=Math.sqrt(dissipationRate*loadRate);if(startLevel===settled)return settled;if(startLevel<settled){return settled*Math.tanh(rate*seconds+Math.atanh(startLevel/settled))}return settled/Math.tanh(rate*seconds+Math.atanh(settled/startLevel))}function belowOneSecondsToLevel(heatCapacity,heatDissipation,thermalLoad,startLevel,targetLevel){const dissipationRate=heatDissipation/heatCapacity;if(heatDissipation===0){if(targetLevel<startLevel||thermalLoad===0)return Infinity;return(targetLevel-startLevel)*heatCapacity/thermalLoad}if(thermalLoad===0){if(targetLevel>startLevel)return Infinity;if(targetLevel===0)return Infinity;return(1/targetLevel-1/startLevel)/dissipationRate}const loadRate=thermalLoad/heatCapacity;const settled=Math.sqrt(loadRate/dissipationRate);const rate=Math.sqrt(dissipationRate*loadRate);if(targetLevel>startLevel?targetLevel>=settled:targetLevel<=settled)return Infinity;const from=startLevel<settled?startLevel/settled:settled/startLevel;const to=startLevel<settled?targetLevel/settled:settled/targetLevel;return(Math.atanh(to)-Math.atanh(from))/rate}function clamp(value){return Math.min(Math.max(value,0),1)}function requireNonNegative(caller,what,value){if(!Number.isFinite(value)||value<0){throw new RangeError(`${caller}: ${what} must be a finite non-negative number`)}return value}function validateHeatParams(caller,heatCapacity,heatDissipation,thermalLoad,startLevel){requireNonNegative(caller,"heat capacity",heatCapacity);requireNonNegative(caller,"heat dissipation",heatDissipation);requireNonNegative(caller,"thermal load",thermalLoad);requireNonNegative(caller,"start level",startLevel);if(heatCapacity===0)throw new RangeError(`${caller}: heat capacity must be above 0`)}export{OVERHEAT_HEAT_LEVEL,effectiveWeaponThermalLoad,equilibriumHeatLevel,heatLevelAtTime,heatMetrics,secondsToHeatLevel};//# sourceMappingURL=chunk-QMQHIZGS.js.map
1
+ var OVERHEAT_HEAT_LEVEL=1.5;var DRAINED_CAPACITOR_MULTIPLIER=5;function equilibriumHeatLevel(dissipation,thermalLoad){requireNonNegative("equilibriumHeatLevel","dissipation",dissipation);requireNonNegative("equilibriumHeatLevel","thermal load",thermalLoad);if(dissipation===0)return thermalLoad===0?0:Infinity;return Math.sqrt(thermalLoad/dissipation)}function effectiveWeaponThermalLoad(thermalLoad,distributorDraw,weaponsCapacity,capacitorLevel){requireNonNegative("effectiveWeaponThermalLoad","thermal load",thermalLoad);requireNonNegative("effectiveWeaponThermalLoad","distributor draw",distributorDraw);requireNonNegative("effectiveWeaponThermalLoad","weapons capacity",weaponsCapacity);requireNonNegative("effectiveWeaponThermalLoad","capacitor level",capacitorLevel);if(capacitorLevel>1){throw new RangeError("effectiveWeaponThermalLoad: capacitor level must be at most 1")}if(weaponsCapacity===0){return thermalLoad*(distributorDraw>0?DRAINED_CAPACITOR_MULTIPLIER:1)}const shortfall=clamp(1-(weaponsCapacity*capacitorLevel-distributorDraw)/weaponsCapacity);return thermalLoad*(1+(DRAINED_CAPACITOR_MULTIPLIER-1)*shortfall)}function heatLevelAtTime(params){const{heatCapacity:heatCapacity,heatDissipation:heatDissipation,thermalLoad:thermalLoad,startLevel:startLevel,seconds:seconds}=params;validateHeatParams("heatLevelAtTime",heatCapacity,heatDissipation,thermalLoad,startLevel);requireNonNegative("heatLevelAtTime","seconds",seconds);if(seconds===0)return startLevel;const linearRate=(thermalLoad-heatDissipation)/heatCapacity;if(startLevel>=1){if(linearRate>=0)return startLevel+linearRate*seconds;const secondsToOne=(startLevel-1)/-linearRate;if(seconds<=secondsToOne)return startLevel+linearRate*seconds;return belowOneLevelAtTime(heatCapacity,heatDissipation,thermalLoad,1,seconds-secondsToOne)}if(thermalLoad>heatDissipation){const secondsToOne=belowOneSecondsToLevel(heatCapacity,heatDissipation,thermalLoad,startLevel,1);if(seconds>secondsToOne)return 1+linearRate*(seconds-secondsToOne)}return belowOneLevelAtTime(heatCapacity,heatDissipation,thermalLoad,startLevel,seconds)}function secondsToHeatLevel(params){const{heatCapacity:heatCapacity,heatDissipation:heatDissipation,thermalLoad:thermalLoad,startLevel:startLevel,targetLevel:targetLevel}=params;validateHeatParams("secondsToHeatLevel",heatCapacity,heatDissipation,thermalLoad,startLevel);requireNonNegative("secondsToHeatLevel","target level",targetLevel);if(targetLevel===startLevel)return 0;const linearRate=(thermalLoad-heatDissipation)/heatCapacity;if(targetLevel>startLevel){let seconds2=0;let level2=startLevel;if(level2<1){const to=Math.min(targetLevel,1);seconds2=belowOneSecondsToLevel(heatCapacity,heatDissipation,thermalLoad,level2,to);if(!Number.isFinite(seconds2)||targetLevel<=1)return seconds2;level2=1}if(linearRate<=0)return Infinity;return seconds2+(targetLevel-level2)/linearRate}let seconds=0;let level=startLevel;if(level>1){if(linearRate>=0)return Infinity;const to=Math.max(targetLevel,1);seconds=(level-to)/-linearRate;if(targetLevel>=1)return seconds;level=1}return seconds+belowOneSecondsToLevel(heatCapacity,heatDissipation,thermalLoad,level,targetLevel)}function heatMetrics(input){const{heatCapacity:heatCapacity,heatDissipation:heatDissipation,heatEfficiency:heatEfficiency}=input;requireNonNegative("heatMetrics","heat capacity",heatCapacity);requireNonNegative("heatMetrics","heat dissipation",heatDissipation);if(heatCapacity===0)throw new RangeError("heatMetrics: heat capacity must be above 0");requireNonNegative("heatMetrics","heat efficiency",heatEfficiency);const retracted=requireNonNegative("heatMetrics","retracted power draw",input.retractedPowerDraw??0);const deployed=requireNonNegative("heatMetrics","deployed power draw",input.deployedPowerDraw??retracted);const thrusterHeat=requireNonNegative("heatMetrics","thruster heat rate",input.thrusterHeatRate??0);const deployedThrusterHeat=requireNonNegative("heatMetrics","deployed thruster heat rate",input.deployedThrusterHeatRate??thrusterHeat);const fsdHeat=requireNonNegative("heatMetrics","FSD heat rate",input.fsdHeatRate??0);const weaponsCapacity=requireNonNegative("heatMetrics","weapons capacity",input.weaponsCapacity??0);const idleLoad=retracted*heatEfficiency;const deployedLoad=deployed*heatEfficiency;const weaponHeat=capacitorLevel=>(input.weapons??[]).reduce((total,weapon)=>total+effectiveWeaponThermalLoad(weapon.heatPerSecond??0,weapon.distributorDraw??0,weaponsCapacity,capacitorLevel),0);const firingBase=deployedLoad+deployedThrusterHeat;const state=(load,base)=>heatState(heatCapacity,heatDissipation,load,base);return{heatEfficiency:heatEfficiency,hullHeatCapacity:heatCapacity,hullHeatDissipation:heatDissipation,idle:state(idleLoad,0),thrusters:state(idleLoad+thrusterHeat,idleLoad),fsdCharging:state(idleLoad+thrusterHeat+fsdHeat,idleLoad+thrusterHeat),firingSustained:state(firingBase+weaponHeat(1),firingBase),firingDrained:state(firingBase+weaponHeat(0),firingBase),unknownDraws:[...input.unknownDraws??[]],unknownWeaponHeat:[...input.unknownWeaponHeat??[]]}}function heatState(heatCapacity,heatDissipation,thermalLoad,baseLoad){const overheats=thermalLoad>heatDissipation;const heatLevel=overheats?Infinity:equilibriumHeatLevel(heatDissipation,thermalLoad);const baseLevel=baseLoad>heatDissipation?1:equilibriumHeatLevel(heatDissipation,baseLoad);return{thermalLoad:thermalLoad,heatLevel:heatLevel,gauge:heatLevel/OVERHEAT_HEAT_LEVEL,overheats:overheats,secondsToOverheat:overheats?secondsToHeatLevel({heatCapacity:heatCapacity,heatDissipation:heatDissipation,thermalLoad:thermalLoad,startLevel:baseLevel,targetLevel:OVERHEAT_HEAT_LEVEL}):null}}function belowOneLevelAtTime(heatCapacity,heatDissipation,thermalLoad,startLevel,seconds){const dissipationRate=heatDissipation/heatCapacity;if(heatDissipation===0)return startLevel+thermalLoad/heatCapacity*seconds;if(thermalLoad===0){if(startLevel===0)return 0;return 1/(1/startLevel+dissipationRate*seconds)}const loadRate=thermalLoad/heatCapacity;const settled=Math.sqrt(loadRate/dissipationRate);const rate=Math.sqrt(dissipationRate*loadRate);if(startLevel===settled)return settled;if(startLevel<settled){return settled*Math.tanh(rate*seconds+Math.atanh(startLevel/settled))}return settled/Math.tanh(rate*seconds+Math.atanh(settled/startLevel))}function belowOneSecondsToLevel(heatCapacity,heatDissipation,thermalLoad,startLevel,targetLevel){const dissipationRate=heatDissipation/heatCapacity;if(heatDissipation===0){if(targetLevel<startLevel||thermalLoad===0)return Infinity;return(targetLevel-startLevel)*heatCapacity/thermalLoad}if(thermalLoad===0){if(targetLevel>startLevel)return Infinity;if(targetLevel===0)return Infinity;return(1/targetLevel-1/startLevel)/dissipationRate}const loadRate=thermalLoad/heatCapacity;const settled=Math.sqrt(loadRate/dissipationRate);const rate=Math.sqrt(dissipationRate*loadRate);if(targetLevel>startLevel?targetLevel>=settled:targetLevel<=settled)return Infinity;const from=startLevel<settled?startLevel/settled:settled/startLevel;const to=startLevel<settled?targetLevel/settled:settled/targetLevel;return(Math.atanh(to)-Math.atanh(from))/rate}function clamp(value){return Math.min(Math.max(value,0),1)}function requireNonNegative(caller,what,value){if(!Number.isFinite(value)||value<0){throw new RangeError(`${caller}: ${what} must be a finite non-negative number`)}return value}function validateHeatParams(caller,heatCapacity,heatDissipation,thermalLoad,startLevel){requireNonNegative(caller,"heat capacity",heatCapacity);requireNonNegative(caller,"heat dissipation",heatDissipation);requireNonNegative(caller,"thermal load",thermalLoad);requireNonNegative(caller,"start level",startLevel);if(heatCapacity===0)throw new RangeError(`${caller}: heat capacity must be above 0`)}export{OVERHEAT_HEAT_LEVEL,effectiveWeaponThermalLoad,equilibriumHeatLevel,heatLevelAtTime,heatMetrics,secondsToHeatLevel};//# sourceMappingURL=chunk-YU5GND2Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ships/heat.ts"],"names":["OVERHEAT_HEAT_LEVEL","DRAINED_CAPACITOR_MULTIPLIER","equilibriumHeatLevel","dissipation","thermalLoad","requireNonNegative","Infinity","Math","sqrt","effectiveWeaponThermalLoad","distributorDraw","weaponsCapacity","capacitorLevel","RangeError","shortfall","clamp","heatLevelAtTime","params","heatCapacity","heatDissipation","startLevel","seconds","validateHeatParams","linearRate","secondsToOne","belowOneLevelAtTime","belowOneSecondsToLevel","secondsToHeatLevel","targetLevel","level","to","min","Number","isFinite","max","heatMetrics","input","heatEfficiency","retracted","retractedPowerDraw","deployed","deployedPowerDraw","thrusterHeat","thrusterHeatRate","deployedThrusterHeat","deployedThrusterHeatRate","fsdHeat","fsdHeatRate","idleLoad","deployedLoad","weaponHeat","weapons","reduce","total","weapon","heatPerSecond","firingBase","state","load","base","heatState","hullHeatCapacity","hullHeatDissipation","idle","thrusters","fsdCharging","firingSustained","firingDrained","unknownDraws","unknownWeaponHeat","baseLoad","overheats","heatLevel","baseLevel","gauge","secondsToOverheat","dissipationRate","loadRate","settled","rate","tanh","atanh","from","value","caller","what"],"mappings":"AA8EO,IAAMA,oBAAsB,IAMnC,IAAMC,6BAA+B,EA+N9B,SAASC,qBAAqBC,YAAqBC,aACtDC,mBAAmB,uBAAwB,cAAeF,aAC1DE,mBAAmB,uBAAwB,eAAgBD,aAC3D,GAAID,cAAgB,EAAG,OAAOC,cAAgB,EAAI,EAAIE,SACtD,OAAOC,KAAKC,KAAKJ,YAAcD,YACnC,CAwBO,SAASM,2BACZL,YACAM,gBACAC,gBACAC,gBAEAP,mBAAmB,6BAA8B,eAAgBD,aACjEC,mBAAmB,6BAA8B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IxB,KAAK2B,IAAIiD,MAAO,GAAI,EACxC,CAEA,SAAS9E,mBAAmB+E,OAAgBC,KAAcF,OACtD,IAAKnD,OAAOC,SAASkD,QAAUA,MAAQ,EAAG,CACtC,MAAM,IAAItE,WAAW,GAAGuE,WAAWC,4CACvC,CACA,OAAOF,KACX,CAEA,SAAS7D,mBACL8D,OACAlE,aACAC,gBACAf,YACAgB,YAEAf,mBAAmB+E,OAAQ,gBAAiBlE,cAC5Cb,mBAAmB+E,OAAQ,mBAAoBjE,iBAC/Cd,mBAAmB+E,OAAQ,eAAgBhF,aAC3CC,mBAAmB+E,OAAQ,cAAehE,YAC1C,GAAIF,eAAiB,EAAG,MAAM,IAAIL,WAAW,GAAGuE,wCACpD,QAAApF,oBAAAS,2BAAAP,qBAAAc,gBAAAmB,YAAAR"}
@@ -167,6 +167,15 @@ interface HeatInput {
167
167
  * states what goes wrong and in which directions.
168
168
  */
169
169
  readonly unknownDraws?: readonly string[];
170
+ /**
171
+ * Enabled, powered hardpoints whose weapon stats could not be resolved, named.
172
+ * Defaults to none.
173
+ *
174
+ * @remarks
175
+ * Passing them does not change a figure; it carries the omitted heat sources into
176
+ * {@link HeatMetrics.unknownWeaponHeat}. Only the two firing scenarios are affected.
177
+ */
178
+ readonly unknownWeaponHeat?: readonly string[];
170
179
  }
171
180
  /** A build's heat under one set of circumstances. */
172
181
  interface HeatState {
@@ -248,6 +257,19 @@ interface HeatMetrics {
248
257
  * settled level. A caller showing these figures should say what they are.
249
258
  */
250
259
  readonly unknownDraws: readonly string[];
260
+ /**
261
+ * Enabled, powered hardpoints omitted because their weapon heat could not be
262
+ * resolved, named by slot. Normally empty.
263
+ *
264
+ * @remarks
265
+ * While this is not empty, {@link firingSustained} and {@link firingDrained} are
266
+ * projections over the weapons that did resolve. Taken alone, the missing
267
+ * contribution is non-negative, so their thermal loads are lower bounds, but their
268
+ * heat levels, `overheats` flags and overheating times are not complete answers for
269
+ * the build. If {@link unknownDraws} is also non-empty, its priority-group uncertainty
270
+ * means no bound holds. The non-firing scenarios are unaffected.
271
+ */
272
+ readonly unknownWeaponHeat: readonly string[];
251
273
  }
252
274
  /**
253
275
  * The heat level a thermal load settles at.
@@ -1 +1 @@
1
- export{OVERHEAT_HEAT_LEVEL,effectiveWeaponThermalLoad,equilibriumHeatLevel,heatLevelAtTime,heatMetrics,secondsToHeatLevel}from"../chunk-QMQHIZGS.js";//# sourceMappingURL=heat.js.map
1
+ export{OVERHEAT_HEAT_LEVEL,effectiveWeaponThermalLoad,equilibriumHeatLevel,heatLevelAtTime,heatMetrics,secondsToHeatLevel}from"../chunk-YU5GND2Q.js";//# sourceMappingURL=heat.js.map
@@ -1 +1 @@
1
- export{LoadoutEditError,ShipLoadout}from"../chunk-WVKRSRLO.js";export{shieldMassCurveMultiplier,shieldMetrics,shieldStrength}from"../chunk-2FHHMYDC.js";export{SHIPS,getShipByName,getShipBySymbol,getShipSlots}from"../chunk-WNGQ3IAM.js";export{getLoadoutModifier,inspectSlef,parseSlef,stringifySlef,toSlef}from"../chunk-UXFMVZAY.js";export{getSourceModuleValue,sourcePurchaseFromLoadout,sumSourceModuleValues}from"../chunk-IYU4WLFM.js";export{weaponsCapacitorMetrics}from"../chunk-FMPRCYKY.js";export{powerBudget}from"../chunk-BMM6GQAU.js";export{getPreEngineeredJournalModifiers,getPreEngineeredModifiers,getPreEngineeredStats,identifyPreEngineeredVariant,unresolvedModifiers}from"../chunk-Q4E2V6RE.js";export{armourPiercingFactor,combinedRateOfFire,damageFalloff,damagePerSecond,energyPerSecond,heatPerSecond,splitDamage,sumWeaponMetrics,sustainedDamagePerSecond,sustainedFireFactor,weaponMetrics}from"../chunk-LJI7VXJD.js";export{getBulkheadsForShip,getModuleBySymbol,getModulesByName}from"../chunk-R26GVRMI.js";export{PRE_ENGINEERED_MODULES,getPreEngineeredVariants,isPreEngineered}from"../chunk-EU42PAV4.js";export{cellBankSummary,shieldRecovery}from"../chunk-VZZUNSDF.js";export{calculateCargoCapacity,calculateFuelCapacity,calculateUnladenMass}from"../chunk-GOMBLS2T.js";export{validateLoadout}from"../chunk-VKN65H2U.js";export{mobilityMetrics,thrusterMassCurveMultiplier}from"../chunk-24INI4U7.js";export{hasFrameShiftDriveJumpStats,hasMassCurveStats,hasPowerDistributorStats,hasPowerGenerationStats,hasShieldRegenerationStats,hasWeaponDamageStats}from"../chunk-JTQVWIGL.js";export{SHIP_MODULE_LIMITS,calculateModuleLimits}from"../chunk-KPETDYQX.js"; export{EXPERIMENTAL_EFFECTS,getExperimentalEffect}from"../chunk-PHPLZEFS.js";export{SHIP_GUNSIGHTS,getShipGunsight,projectGunsight}from"../chunk-UBYO7VZR.js";export{OVERHEAT_HEAT_LEVEL,effectiveWeaponThermalLoad,equilibriumHeatLevel,heatLevelAtTime,heatMetrics,secondsToHeatLevel}from"../chunk-QMQHIZGS.js";export{frameShiftDriveMassFactor,fuelPerJump,singleJumpRange,totalRange}from"../chunk-GQ5GX5TB.js";export{ammunitionCapacity}from"../chunk-AA3K5XUE.js";export{armourMetrics}from"../chunk-FGXWVFN6.js";export{effectiveHitPoints,mapDamageTypes,stackArmourResistance,stackShieldResistance,systemsResistance}from"../chunk-ZNCXENNB.js";export{computeModifiers,rollsForGrade,sumMaterials}from"../chunk-SVZARHWP.js";export{resolveBlueprintForModule}from"../chunk-W5G2NUCZ.js";export{ENGINEERING_OPTION_GROUPS,getBlueprintsForModule,getEngineeringGroup,getExperimentalsForBlueprint,getExperimentalsForModule}from"../chunk-QTZPA2FR.js";export{BLUEPRINTS,getBlueprint,getBlueprintGrade}from"../chunk-QI22FKBG.js"; export{distributorMetrics}from"../chunk-P2QOL63K.js"; export{SLOT_RESTRICTION_LABELS,enumerateSlots,parseSlotName}from"../chunk-RAO35XDF.js"; //# sourceMappingURL=index.js.map
1
+ export{LoadoutEditError,ShipLoadout}from"../chunk-VSNS7Y3M.js";export{shieldMassCurveMultiplier,shieldMetrics,shieldStrength}from"../chunk-2FHHMYDC.js";export{SHIPS,getShipByName,getShipBySymbol,getShipSlots}from"../chunk-WNGQ3IAM.js";export{getLoadoutModifier,inspectSlef,parseSlef,stringifySlef,toSlef}from"../chunk-UXFMVZAY.js";export{getSourceModuleValue,sourcePurchaseFromLoadout,sumSourceModuleValues}from"../chunk-IYU4WLFM.js";export{weaponsCapacitorMetrics}from"../chunk-FMPRCYKY.js";export{powerBudget}from"../chunk-BMM6GQAU.js";export{getPreEngineeredJournalModifiers,getPreEngineeredModifiers,getPreEngineeredStats,identifyPreEngineeredVariant,unresolvedModifiers}from"../chunk-Q4E2V6RE.js";export{armourPiercingFactor,combinedRateOfFire,damageFalloff,damagePerSecond,energyPerSecond,heatPerSecond,splitDamage,sumWeaponMetrics,sustainedDamagePerSecond,sustainedFireFactor,weaponMetrics}from"../chunk-LJI7VXJD.js";export{getBulkheadsForShip,getModuleBySymbol,getModulesByName}from"../chunk-R26GVRMI.js";export{PRE_ENGINEERED_MODULES,getPreEngineeredVariants,isPreEngineered}from"../chunk-EU42PAV4.js";export{cellBankSummary,shieldRecovery}from"../chunk-VZZUNSDF.js";export{calculateCargoCapacity,calculateFuelCapacity,calculateUnladenMass}from"../chunk-GOMBLS2T.js";export{validateLoadout}from"../chunk-VKN65H2U.js";export{mobilityMetrics,thrusterMassCurveMultiplier}from"../chunk-24INI4U7.js";export{hasFrameShiftDriveJumpStats,hasMassCurveStats,hasPowerDistributorStats,hasPowerGenerationStats,hasShieldRegenerationStats,hasWeaponDamageStats}from"../chunk-JTQVWIGL.js";export{SHIP_MODULE_LIMITS,calculateModuleLimits}from"../chunk-KPETDYQX.js"; export{EXPERIMENTAL_EFFECTS,getExperimentalEffect}from"../chunk-PHPLZEFS.js";export{SHIP_GUNSIGHTS,getShipGunsight,projectGunsight}from"../chunk-UBYO7VZR.js";export{OVERHEAT_HEAT_LEVEL,effectiveWeaponThermalLoad,equilibriumHeatLevel,heatLevelAtTime,heatMetrics,secondsToHeatLevel}from"../chunk-YU5GND2Q.js";export{frameShiftDriveMassFactor,fuelPerJump,singleJumpRange,totalRange}from"../chunk-GQ5GX5TB.js";export{ammunitionCapacity}from"../chunk-AA3K5XUE.js";export{armourMetrics}from"../chunk-FGXWVFN6.js";export{effectiveHitPoints,mapDamageTypes,stackArmourResistance,stackShieldResistance,systemsResistance}from"../chunk-ZNCXENNB.js";export{computeModifiers,rollsForGrade,sumMaterials}from"../chunk-SVZARHWP.js";export{resolveBlueprintForModule}from"../chunk-W5G2NUCZ.js";export{ENGINEERING_OPTION_GROUPS,getBlueprintsForModule,getEngineeringGroup,getExperimentalsForBlueprint,getExperimentalsForModule}from"../chunk-QTZPA2FR.js";export{BLUEPRINTS,getBlueprint,getBlueprintGrade}from"../chunk-QI22FKBG.js"; export{distributorMetrics}from"../chunk-P2QOL63K.js"; export{SLOT_RESTRICTION_LABELS,enumerateSlots,parseSlotName}from"../chunk-RAO35XDF.js"; //# sourceMappingURL=index.js.map
@@ -1487,11 +1487,12 @@ declare class ShipLoadout {
1487
1487
  * cannot keep lit — contributes nothing.
1488
1488
  *
1489
1489
  * @returns The {@link HeatMetrics}, or `null` when the build has no powered power
1490
- * plant. A build carrying a module the catalogues cannot
1491
- * resolve is answered rather than refused, with that module named in
1492
- * {@link HeatMetrics.unknownDraws}: read what that entry says about the figures
1493
- * before showing them, because they are then a projection over the rest of the build
1494
- * rather than an answer for it.
1490
+ * plant. A build carrying a module the catalogues cannot resolve is answered rather
1491
+ * than refused. {@link HeatMetrics.unknownDraws} names unknown power contributions;
1492
+ * {@link HeatMetrics.unknownWeaponHeat} names unresolved hardpoints omitted from the
1493
+ * firing scenarios. Read those entries before showing the figures, because a
1494
+ * non-empty diagnostic makes the affected results projections over the rest of the
1495
+ * build rather than complete answers.
1495
1496
  * @example
1496
1497
  * ```ts
1497
1498
  * import type { ShipLoadout } from '@elite-dangerous-almanac/core/ships/ship-loadout';
@@ -1 +1 @@
1
- export{LoadoutEditError,ShipLoadout}from"../chunk-WVKRSRLO.js"; //# sourceMappingURL=ship-loadout.js.map
1
+ export{LoadoutEditError,ShipLoadout}from"../chunk-VSNS7Y3M.js"; //# sourceMappingURL=ship-loadout.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elite-dangerous-almanac/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Elite Dangerous static data and calculations: astronomy, ships and outfitting, personal equipment and engineering, materials, and market commodities.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ships/heat.ts"],"names":["OVERHEAT_HEAT_LEVEL","DRAINED_CAPACITOR_MULTIPLIER","equilibriumHeatLevel","dissipation","thermalLoad","requireNonNegative","Infinity","Math","sqrt","effectiveWeaponThermalLoad","distributorDraw","weaponsCapacity","capacitorLevel","RangeError","shortfall","clamp","heatLevelAtTime","params","heatCapacity","heatDissipation","startLevel","seconds","validateHeatParams","linearRate","secondsToOne","belowOneLevelAtTime","belowOneSecondsToLevel","secondsToHeatLevel","targetLevel","level","to","min","Number","isFinite","max","heatMetrics","input","heatEfficiency","retracted","retractedPowerDraw","deployed","deployedPowerDraw","thrusterHeat","thrusterHeatRate","deployedThrusterHeat","deployedThrusterHeatRate","fsdHeat","fsdHeatRate","idleLoad","deployedLoad","weaponHeat","weapons","reduce","total","weapon","heatPerSecond","firingBase","state","load","base","heatState","hullHeatCapacity","hullHeatDissipation","idle","thrusters","fsdCharging","firingSustained","firingDrained","unknownDraws","baseLoad","overheats","heatLevel","baseLevel","gauge","secondsToOverheat","dissipationRate","loadRate","settled","rate","tanh","atanh","from","value","caller","what"],"mappings":"AA8EO,IAAMA,oBAAsB,IAMnC,IAAMC,6BAA+B,EAyM9B,SAASC,qBAAqBC,YAAqBC,aACtDC,mBAAmB,uBAAwB,cAAeF,aAC1DE,mBAAmB,uBAAwB,eAAgBD,aAC3D,GAAID,cAAgB,EAAG,OAAOC,cAAgB,EAAI,EAAIE,SACtD,OAAOC,KAAKC,KAAKJ,YAAcD,YACnC,CAwBO,SA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A,SAAS/D,MAAMmE,OACX,OAAO3E,KAAKwB,IAAIxB,KAAK2B,IAAIgD,MAAO,GAAI,EACxC,CAEA,SAAS7E,mBAAmB8E,OAAgBC,KAAcF,OACtD,IAAKlD,OAAOC,SAASiD,QAAUA,MAAQ,EAAG,CACtC,MAAM,IAAIrE,WAAW,GAAGsE,WAAWC,4CACvC,CACA,OAAOF,KACX,CAEA,SAAS5D,mBACL6D,OACAjE,aACAC,gBACAf,YACAgB,YAEAf,mBAAmB8E,OAAQ,gBAAiBjE,cAC5Cb,mBAAmB8E,OAAQ,mBAAoBhE,iBAC/Cd,mBAAmB8E,OAAQ,eAAgB/E,aAC3CC,mBAAmB8E,OAAQ,cAAe/D,YAC1C,GAAIF,eAAiB,EAAG,MAAM,IAAIL,WAAW,GAAGsE,wCACpD,QAAAnF,oBAAAS,2BAAAP,qBAAAc,gBAAAmB,YAAAR"}
@@ -1 +0,0 @@
1
- import{shieldMetrics}from"./chunk-2FHHMYDC.js";import{getShipBySymbol,getShipByName}from"./chunk-WNGQ3IAM.js";import{parseSlef,toSlef,stringifySlef,getLoadoutModifier}from"./chunk-UXFMVZAY.js";import{sourcePurchaseFromLoadout,getSourceModuleValue}from"./chunk-IYU4WLFM.js";import{weaponsCapacitorMetrics}from"./chunk-FMPRCYKY.js";import{powerBudget}from"./chunk-BMM6GQAU.js";import{isCargoHatchSlot,matchingKeyIn,ownKeyIn,isBuiltInHullModule,isNonOutfittingSlot,cloneLoadoutModule,identifyPreEngineeredVariant,cloneModuleStats,availableBlueprintsFor,availableExperimentalsFor,blueprintAvailableFor,blueprintRoutesFor,experimentalAvailableFor,primitiveEngineeringInputsFor,missingBaseLabels,journalModifiersFor,getPreEngineeredStats,getPreEngineeredJournalModifiers,getPreEngineeredModifiers,ordinaryEngineeringProof,unresolvedModifiers,orderBySlotLayout,FITTED_ITEM,isFinalGuardianWeaponEngineering,scaleDamageComponents}from"./chunk-Q4E2V6RE.js";import{weaponMetrics,sumWeaponMetrics,combinedRateOfFire}from"./chunk-LJI7VXJD.js";import{builtInModuleBySymbol,getBulkheadsForShip}from"./chunk-R26GVRMI.js";import{getPreEngineeredVariants}from"./chunk-EU42PAV4.js";import{shieldRecovery,cellBankSummary}from"./chunk-VZZUNSDF.js";import{completeResult,calculateUnladenMass,calculateCargoCapacity,calculateFuelCapacity,incompleteResult}from"./chunk-GOMBLS2T.js";import{validateLoadout,fixedSlotReason}from"./chunk-VKN65H2U.js";import{mobilityMetrics}from"./chunk-24INI4U7.js";import{calculateModuleLimits}from"./chunk-KPETDYQX.js";import{ALL_MODULES}from"./chunk-PNZCLQDJ.js";import{CORE_MODULES}from"./chunk-O72KI7RP.js";import{getExperimentalEffect}from"./chunk-PHPLZEFS.js";import{heatMetrics}from"./chunk-QMQHIZGS.js";import{singleJumpRange,frameShiftDriveMassFactor,fuelPerJump,totalRange}from"./chunk-GQ5GX5TB.js";import{ammunitionCapacity}from"./chunk-AA3K5XUE.js";import{armourMetrics}from"./chunk-FGXWVFN6.js";import{baseStats,computeModifiers,labelsForDamageType,scaleForLabel,fieldForLabel,labelsForField,capabilityValueForLabel,damageTypeForLabel}from"./chunk-SVZARHWP.js";import{resolveBlueprintForModule}from"./chunk-W5G2NUCZ.js";import{getExperimentalsForModule}from"./chunk-QTZPA2FR.js";import{getBlueprintGrade}from"./chunk-QI22FKBG.js";import{getDefaultLoadout}from"./chunk-GRIK3EDH.js";import{distributorMetrics}from"./chunk-P2QOL63K.js";import{loadoutSlotName}from"./chunk-KAA4VOOB.js";import{parseSlotName,enumerateSlots,SLOT_RESTRICTION_LABELS}from"./chunk-RAO35XDF.js";import{normalizeKey}from"./chunk-BKWLI44T.js";import{truncate,describeValue,requireString,requireStringIfPresent}from"./chunk-PKWVG2JY.js";import{deepFreeze}from"./chunk-DURKO7JU.js";var PREFIX={powerPlant:["int_powerplant","int_guardianpowerplant"],thrusters:["int_engine","int_mkiiagileboost_engine"],frameShiftDrive:["int_hyperdrive"],powerDistributor:["int_powerdistributor","int_guardianpowerdistributor"],shieldGenerator:["int_shieldgenerator"],shieldCellBank:["int_shieldcellbank"],shieldBooster:["hpt_shieldbooster"],shieldReinforcement:["int_guardianshieldreinforcement"],hullReinforcement:["int_hullreinforcement","int_guardianhullreinforcement","int_metaalloyhullreinforcement"],moduleReinforcement:["int_modulereinforcement","int_guardianmodulereinforcement"]};var startsWithAny=(symbol,prefixes)=>prefixes.some(prefix=>symbol.toLowerCase().startsWith(prefix));function isPowerDistributor(module,stats){return stats?.slot?stats.slot==="powerDistributor":startsWithAny(module.Item,PREFIX.powerDistributor)}function isPowerPlant(module,stats){const parsed=parseSlotName(module.Slot);if(parsed?.kind==="core"&&parsed.core==="powerPlant")return true;return stats?.slot?stats.slot==="powerPlant":startsWithAny(module.Item,PREFIX.powerPlant)}function isThruster(module,stats){const parsed=parseSlotName(module.Slot);if(parsed?.kind==="core"&&parsed.core==="thrusters")return true;return stats?.slot?stats.slot==="thrusters":startsWithAny(module.Item,PREFIX.thrusters)}function isFrameShiftDrive(module,stats){const parsed=parseSlotName(module.Slot);if(parsed?.kind==="core"&&parsed.core==="frameShiftDrive")return true;return stats?.slot?stats.slot==="frameShiftDrive":startsWithAny(module.Item,PREFIX.frameShiftDrive)}function isEnabled(module){return module.On!==false}function priorityOf(module){return(module.Priority??0)+1}function effectiveStat(module,field,stats){const stated=statedModifier(module,field);if(stated!==void 0)return stated;const base=stats?.[field];return typeof base==="number"?base:void 0}function statedModifier(module,field){for(const label of labelsForField(field)){if(capabilityValueForLabel(label)!==null)continue;const modified=getLoadoutModifier(module,label);if(modified!==null)return modified/scaleForLabel(label)}return void 0}function effectiveCapability(module,field,stats){for(const label of labelsForField(field)){if(capabilityValueForLabel(label)===null)continue;if(module.Engineering?.Modifiers?.some(modifier=>modifier.Label.toLowerCase()===label.toLowerCase())){return true}}const base=stats[field];return typeof base==="boolean"?base:void 0}function effectiveDamageDistribution(module,stats){const fromEffect=module.Engineering?.ExperimentalEffect?getExperimentalEffect(module.Engineering.ExperimentalEffect)?.damageDistribution:void 0;const distribution={...fromEffect??stats.damageDistribution};let resolved=fromEffect!==void 0||stats.damageDistribution!==void 0;const seen=/* @__PURE__ */new Set;for(const modifier of module.Engineering?.Modifiers??[]){const type=damageTypeForLabel(modifier.Label);if(type===null||seen.has(type))continue;seen.add(type);if(modifier.Value===void 0)continue;distribution[type]=modifier.Value/scaleForLabel(modifier.Label);resolved=true}return resolved?distribution:void 0}function convertsDamage(module){if(module.Engineering?.ExperimentalEffect&&getExperimentalEffect(module.Engineering.ExperimentalEffect)?.damageDistribution){return true}return(module.Engineering?.Modifiers??[]).some(modifier=>damageTypeForLabel(modifier.Label)!==null)}function modifierRatio(module,stats,field){const base=stats?.[field];if(typeof base!=="number"||base===0)return 1;const effective=effectiveStat(module,field,stats);return effective===void 0?1:effective/base}function relatedStat(module,stats,field,ratio){const stated=statedModifier(module,field);if(stated!==void 0)return stated;const base=stats?.[field];return typeof base==="number"?base*ratio:void 0}function effectiveModule(module,stats){if(!stats||!module.Engineering)return stats;const merged={...stats};const fields=new Set(Object.keys(stats));for(const modifier of module.Engineering.Modifiers??[]){const field=fieldForLabel(modifier.Label,stats);if(field)fields.add(field)}for(const key of fields){const capability=effectiveCapability(module,key,stats);if(capability!==void 0){merged[key]=capability;continue}const value=effectiveStat(module,key,stats);if(value!==void 0)merged[key]=value}if(stats.engineeringGroup==="thrusters"){const massRatio=modifierRatio(module,stats,"optMass");const minMass=relatedStat(module,stats,"minMass",massRatio);const maxMass=relatedStat(module,stats,"maxMass",massRatio);if(minMass!==void 0)merged.minMass=minMass;if(maxMass!==void 0)merged.maxMass=maxMass}if(stats.engineeringGroup==="thrusters"||stats.engineeringGroup==="shieldGenerators"){const performanceRatio=modifierRatio(module,stats,"optMultiplier");const minMultiplier=relatedStat(module,stats,"minMultiplier",performanceRatio);const maxMultiplier=relatedStat(module,stats,"maxMultiplier",performanceRatio);if(minMultiplier!==void 0)merged.minMultiplier=minMultiplier;if(maxMultiplier!==void 0)merged.maxMultiplier=maxMultiplier;if(stats.engineeringGroup==="thrusters"){for(const field of["minSpeedMultiplier","optSpeedMultiplier","maxSpeedMultiplier","minRotationMultiplier","optRotationMultiplier","maxRotationMultiplier"]){const value=stats[field];if(value!==void 0)merged[field]=value*performanceRatio}}}const damageDistribution=effectiveDamageDistribution(module,stats);if(damageDistribution)merged.damageDistribution=damageDistribution;if(stats.category==="hardpoint")normalizeEffectiveWeapon(module,merged);if(convertsDamage(module)){delete merged.damageComponents}else if(stats.damageComponents){merged.damageComponents=scaleDamageComponents(stats.damageComponents,stats.damage,typeof merged.damage==="number"?merged.damage:void 0)}return merged}function powerConsumerFor(module,stats){const draw=effectiveStat(module,"powerDraw",stats);const parsedSlot=parseSlotName(module.Slot);const mounted=stats?.category==="hardpoint"||stats?.category==="utility";const deployedOnly=stats!==null?mounted&&stats.alwaysPowered!==true:parsedSlot?.kind==="hardpoint"?true:parsedSlot?.kind==="utility"?null:false;const common={priority:priorityOf(module),enabled:isEnabled(module),deployedOnly:deployedOnly,label:module.Slot,symbol:module.Item};if(draw===void 0){const inherentlyPassiveSlot=parsedSlot?.kind==="armour"||parsedSlot?.kind==="core"&&(parsedSlot.core==="powerPlant"||parsedSlot.core==="fuelTank");if(stats!==null||inherentlyPassiveSlot||isNonOutfittingSlot(module.Slot))return null;return{drawUnknown:true,...common}}if(draw===0)return null;return{draw:draw,...common}}function powerAvailable(modules,statsFor){for(const module of modules){const stats=statsFor(module);if(!isPowerPlant(module,stats))continue;if(!isEnabled(module))return 0;return effectiveStat(module,"powerCapacity",stats)??0}return 0}function metricIssue(field,reason,module){const defaultSlot=field==="powerCapacity"?"PowerPlant":field==="thrusters"?"MainEngines":void 0;const slot=module?.Slot??defaultSlot;const symbol=module?.Item;const params={field:field,reason:reason,...slot===void 0?{}:{slot:slot},...symbol===void 0?{}:{symbol:symbol}};let message;if(reason==="missing"){message=field==="powerCapacity"?"PowerPlant: no power plant is fitted":field==="thrusters"?"MainEngines: no thrusters are fitted":"no shield generator is fitted"}else if(reason==="unresolved"){const unavailable=field==="thrusters"?"thruster stats":field==="shieldGenerator"?"shield-generator stats":field==="powerCapacity"?"power capacity":field;message=`${truncate(slot??field)}: ${unavailable} unavailable for ${truncate(symbol??field)}`}else if(reason==="disabled"){message=`${truncate(slot??field)}: ${truncate(symbol??field)} is switched off`}else if(reason==="invalid"){message=`${truncate(slot??field)}: ${truncate(symbol??field)} has invalid ${field}`}else{message=`${truncate(slot??field)}: ${truncate(symbol??field)} is not powered with hardpoints retracted`}return{field:field,reason:reason,...slot===void 0?{}:{slot:slot},...symbol===void 0?{}:{symbol:symbol},message:message,params:params}}function powerPlantIssueFor(modules,statsFor){for(const module of modules){const stats=statsFor(module);if(!isPowerPlant(module,stats))continue;if(!isEnabled(module))return metricIssue("powerCapacity","disabled",module);const capacity=effectiveStat(module,"powerCapacity",stats);if(capacity===void 0)return metricIssue("powerCapacity","unresolved",module);return!Number.isFinite(capacity)||capacity<=0?metricIssue("powerCapacity","invalid",module):null}return metricIssue("powerCapacity","missing")}function powerDrawIssueFor(modules,statsFor){for(const module of modules){const consumer=powerConsumerFor(module,statsFor(module));if(consumer&&!consumer.drawUnknown&&(consumer.draw===void 0||!Number.isFinite(consumer.draw)||consumer.draw<0)){return metricIssue("powerDraw","invalid",module)}}return null}function poweredMetricBudgetFor(field,module,stats,modules,getBudget,statsFor){if(!isEnabled(module))return incompleteResult([metricIssue(field,"disabled",module)]);const plantIssue=powerPlantIssueFor(modules,statsFor);if(plantIssue)return incompleteResult([plantIssue]);const drawIssue=powerDrawIssueFor(modules,statsFor);if(drawIssue)return incompleteResult([drawIssue]);const budget=getBudget();return budget.available>0&&poweredStates(module,stats,budget).retracted?completeResult(budget):incompleteResult([metricIssue(field,"shed",module)])}function poweredShieldGeneratorResultFor(modules,getBudget,statsFor){for(const module of modules){if(!startsWithAny(module.Item,PREFIX.shieldGenerator))continue;const stats=statsFor(module);const powered=poweredMetricBudgetFor("shieldGenerator",module,stats,modules,getBudget,statsFor);if(!powered.complete)return powered;return stats===null?incompleteResult([metricIssue("shieldGenerator","unresolved",module)]):completeResult({module:module,budget:powered.value})}return incompleteResult([metricIssue("shieldGenerator","missing")])}function mapResistanceFields(read){return{kineticResistance:read("kineticResistance")??0,thermalResistance:read("thermalResistance")??0,explosiveResistance:read("explosiveResistance")??0,causticResistance:read("causticResistance")??0}}function resistancesOf(module,stats){return mapResistanceFields(field=>effectiveStat(module,field,stats))}function shieldInputFor(ship,modules,budget,systemsPips,statsFor){let generator=null;const boosters=[];let reinforcement=0;for(const module of modules){if(!isEnabled(module))continue;const stats=statsFor(module);if(!(budget.available>0&&poweredStates(module,stats,budget).retracted))continue;if(!generator&&startsWithAny(module.Item,PREFIX.shieldGenerator)){const massRatio=modifierRatio(module,stats,"optMass");const strengthRatio=modifierRatio(module,stats,"optMultiplier");const optMass=effectiveStat(module,"optMass",stats);const minMass=relatedStat(module,stats,"minMass",massRatio);const maxMass=relatedStat(module,stats,"maxMass",Math.max(1,massRatio));const optMultiplier=effectiveStat(module,"optMultiplier",stats);const minMultiplier=relatedStat(module,stats,"minMultiplier",strengthRatio);const maxMultiplier=relatedStat(module,stats,"maxMultiplier",strengthRatio);generator={...optMass===void 0?{}:{optMass:optMass},...minMass===void 0?{}:{minMass:minMass},...maxMass===void 0?{}:{maxMass:maxMass},...optMultiplier===void 0?{}:{optMultiplier:optMultiplier},...minMultiplier===void 0?{}:{minMultiplier:minMultiplier},...maxMultiplier===void 0?{}:{maxMultiplier:maxMultiplier},...resistancesOf(module,stats)}}else if(startsWithAny(module.Item,PREFIX.shieldBooster)){boosters.push({shieldBoost:effectiveStat(module,"shieldBoost",stats)??0,...resistancesOf(module,stats)})}else if(startsWithAny(module.Item,PREFIX.shieldReinforcement)){reinforcement+=effectiveStat(module,"shieldAddition",stats)??0}}return{hullMass:ship.hullMass,baseShieldStrength:ship.baseShieldStrength,generator:generator,boosters:boosters,reinforcement:reinforcement,systemsPips:systemsPips}}function shieldInputResultFor(ship,modules,getBudget,systemsPips,statsFor){const fitted=poweredShieldGeneratorResultFor(modules,getBudget,statsFor);if(!fitted.complete)return fitted;const input=shieldInputFor(ship,modules,fitted.value.budget,systemsPips,statsFor);return completeResult(input)}function mobilityInputResultFor(ship,modules,getBudget,mass,enginesPips,statsFor){let thrusters=null;for(const module of modules){const stats=statsFor(module);if(!isThruster(module,stats))continue;const powered=poweredMetricBudgetFor("thrusters",module,stats,modules,getBudget,statsFor);if(!powered.complete)return powered;const effective=effectiveModule(module,stats);const minMass=effective?.minMass;const optMass=effective?.optMass;const maxMass=effective?.maxMass;const minMultiplier=effective?.minMultiplier;const optMultiplier=effective?.optMultiplier;const maxMultiplier=effective?.maxMultiplier;if(minMass===void 0||optMass===void 0||maxMass===void 0||minMultiplier===void 0||optMultiplier===void 0||maxMultiplier===void 0){return incompleteResult([metricIssue("thrusters","unresolved",module)])}thrusters={minMass:minMass,optMass:optMass,maxMass:maxMass,minMultiplier:minMultiplier,optMultiplier:optMultiplier,maxMultiplier:maxMultiplier,...effective?.optSpeedMultiplier===void 0?{}:{speedCurve:{minMass:minMass,optMass:optMass,maxMass:maxMass,minMultiplier:effective.minSpeedMultiplier??minMultiplier,optMultiplier:effective.optSpeedMultiplier,maxMultiplier:effective.maxSpeedMultiplier??maxMultiplier}},...effective?.optRotationMultiplier===void 0?{}:{rotationCurve:{minMass:minMass,optMass:optMass,maxMass:maxMass,minMultiplier:effective.minRotationMultiplier??minMultiplier,optMultiplier:effective.optRotationMultiplier,maxMultiplier:effective.maxRotationMultiplier??maxMultiplier}}};break}if(!thrusters)return incompleteResult([metricIssue("thrusters","missing")]);return completeResult({minimumSpeed:ship.minimumSpeed,maximumSpeed:ship.maximumSpeed,boost:ship.boost,minPitch:ship.minPitch,pitch:ship.pitch,minRoll:ship.minRoll,roll:ship.roll,minYaw:ship.minYaw,yaw:ship.yaw,mass:typeof mass==="function"?mass():mass,thrusters:thrusters,enginesPips:enginesPips})}function shieldRecoveryInputResultFor(ship,modules,getBudget,systemsPips,statsFor){const generator=poweredShieldGeneratorResultFor(modules,getBudget,statsFor);if(!generator.complete)return generator;const{module:generatorModule,budget:budget}=generator.value;let distributor=null;for(const module of modules){const stats=statsFor(module);if(isPowerDistributor(module,stats)&&isEnabled(module)&&budget.available>0&&poweredStates(module,stats,budget).retracted)distributor=module}const generatorStats=statsFor(generatorModule);const distributorStats=distributor?statsFor(distributor):null;const strength=shieldMetrics(shieldInputFor(ship,modules,budget,0,statsFor)).strength;return completeResult({strength:strength,regenRate:effectiveStat(generatorModule,"shieldRegenRate",generatorStats)??0,brokenRegenRate:effectiveStat(generatorModule,"shieldBrokenRegenRate",generatorStats)??0,distributorDraw:effectiveStat(generatorModule,"distributorDraw",generatorStats)??.6,systemsCapacity:distributor?effectiveStat(distributor,"systemsCapacity",distributorStats)??0:0,systemsRecharge:distributor?effectiveStat(distributor,"systemsRecharge",distributorStats)??0:0,systemsPips:systemsPips})}function weaponsCapacitorInputFor(modules,weaponsPips,budget,statsFor){let weaponsCapacity=0;let weaponsRecharge=0;let sustainedEnergyPerSecond=0;for(const module of modules){if(!isEnabled(module))continue;const stats=statsFor(module);if(!poweredStates(module,stats,budget).deployed)continue;if(isPowerDistributor(module,stats)){weaponsCapacity=effectiveStat(module,"weaponsCapacity",stats)??0;weaponsRecharge=effectiveStat(module,"weaponsRecharge",stats)??0}const weapon=weaponStatsFor(module,stats);if(weapon){sustainedEnergyPerSecond+=weaponMetrics(weapon).sustainedEnergyPerSecond}}return{weaponsCapacity:weaponsCapacity,weaponsRecharge:weaponsRecharge,sustainedEnergyPerSecond:sustainedEnergyPerSecond,weaponsPips:weaponsPips}}function distributorInputFor(modules,pips,budget,statsFor){for(const module of modules){if(!isEnabled(module))continue;const stats=statsFor(module);if(!isPowerDistributor(module,stats))continue;if(!poweredStates(module,stats,budget).retracted)return null;const systemsCapacity=effectiveStat(module,"systemsCapacity",stats);const systemsRecharge=effectiveStat(module,"systemsRecharge",stats);const enginesCapacity=effectiveStat(module,"enginesCapacity",stats);const enginesRecharge=effectiveStat(module,"enginesRecharge",stats);const weaponsCapacity=effectiveStat(module,"weaponsCapacity",stats);const weaponsRecharge=effectiveStat(module,"weaponsRecharge",stats);if(systemsCapacity===void 0||systemsRecharge===void 0||enginesCapacity===void 0||enginesRecharge===void 0||weaponsCapacity===void 0||weaponsRecharge===void 0){return null}return{systemsCapacity:systemsCapacity,systemsRecharge:systemsRecharge,enginesCapacity:enginesCapacity,enginesRecharge:enginesRecharge,weaponsCapacity:weaponsCapacity,weaponsRecharge:weaponsRecharge,...pips}}return null}function heatInputFor(ship,modules,budget,statsFor){let heatEfficiency;let thrusterHeatRate=0;let deployedThrusterHeatRate=0;let fsdHeatRate=0;let weaponsCapacity=0;const weapons=[];for(const module of modules){const stats=statsFor(module);if(isPowerPlant(module,stats)){if(!isEnabled(module))return null;heatEfficiency=effectiveStat(module,"heatEfficiency",stats);continue}if(!isEnabled(module))continue;const running=poweredStates(module,stats,budget);if(isThruster(module,stats)){const heat=effectiveStat(module,"engineHeatRate",stats)??0;if(running.retracted)thrusterHeatRate+=heat;if(running.deployed)deployedThrusterHeatRate+=heat}else if(isFrameShiftDrive(module,stats)){if(running.retracted)fsdHeatRate+=effectiveStat(module,"fsdHeatRate",stats)??0}else if(isPowerDistributor(module,stats)){if(running.deployed){weaponsCapacity=effectiveStat(module,"weaponsCapacity",stats)??0}}const weapon=weaponStatsFor(module,stats);if(!weapon||!running.deployed)continue;weapons.push({heatPerSecond:weaponMetrics(weapon).sustainedHeatPerSecond,distributorDraw:weapon.distributorDraw??0})}if(heatEfficiency===void 0)return null;return{heatCapacity:ship.heatCapacity,heatDissipation:ship.heatDissipation,heatEfficiency:heatEfficiency,retractedPowerDraw:poweredDraw(budget,"retracted"),deployedPowerDraw:poweredDraw(budget,"deployed"),thrusterHeatRate:thrusterHeatRate,deployedThrusterHeatRate:deployedThrusterHeatRate,fsdHeatRate:fsdHeatRate,weaponsCapacity:weaponsCapacity,weapons:weapons,unknownDraws:budget.unknownDraws.map(consumer=>consumer.label??"(unnamed module)")}}function poweredDraw(budget,state){const powered=state==="retracted"?"poweredRetracted":"poweredDeployed";return budget.bands.reduce((total,band)=>band[powered]?total+band[state]:total,0)}function poweredStates(module,stats,budget){const draw=effectiveStat(module,"powerDraw",stats);if(draw===void 0||draw===0)return{retracted:true,deployed:true};const band=budget.bands[Math.min(budget.bands.length,Math.max(1,priorityOf(module)))-1];if(!band)return{retracted:true,deployed:true};return{retracted:band.poweredRetracted,deployed:band.poweredDeployed}}function cellBankInputsFor(modules,budget,statsFor){const banks=[];for(const module of modules){if(!startsWithAny(module.Item,PREFIX.shieldCellBank))continue;const stats=statsFor(module);const effective=effectiveModule(module,stats);const ammunition=effective?ammunitionCapacity(effective):null;banks.push({slot:module.Slot,symbol:module.Item,reinforcementRate:effective?.shieldBankReinforcement??0,cells:ammunition?.total??0,spinUp:effective?.shieldBankSpinUp??0,duration:effective?.shieldBankDuration??0,heat:effective?.shieldBankHeat??0,powered:budget.available>0&&isEnabled(module)&&poweredStates(module,stats,budget).deployed})}return banks}function stockBulkhead(ship){const variants=getBulkheadsForShip(ship.name,CORE_MODULES);return variants.find(v=>v.symbol.toLowerCase().endsWith("_default"))??variants.find(v=>v.mass===0)??variants[0]??null}function armourInputFor(ship,modules,statsFor){const reinforcements=[];const moduleReinforcements=[];let bulkhead=null;for(const module of modules){if(!isEnabled(module))continue;const stats=statsFor(module);if(module.Slot.toLowerCase()==="armour"){bulkhead={hullBoost:effectiveStat(module,"hullBoost",stats)??0,...resistancesOf(module,stats)}}else if(startsWithAny(module.Item,PREFIX.hullReinforcement)){const boost=getLoadoutModifier(module,"DefenceModifierHealthMultiplier");reinforcements.push({hullReinforcement:effectiveStat(module,"hullReinforcement",stats)??0,hullBoost:boost===null?0:boost/scaleForLabel("DefenceModifierHealthMultiplier"),...resistancesOf(module,stats)})}else if(startsWithAny(module.Item,PREFIX.moduleReinforcement)){moduleReinforcements.push({moduleProtection:effectiveStat(module,"moduleProtection",stats)??0,integrity:effectiveStat(module,"integrity",stats)??0})}}if(!bulkhead){const stock=stockBulkhead(ship);bulkhead=stock?{hullBoost:stock.hullBoost??0,...mapResistanceFields(field=>stock[field])}:null}return{baseArmour:ship.baseArmour,bulkhead:bulkhead,reinforcements:reinforcements,moduleReinforcements:moduleReinforcements}}var WEAPON_FIELDS=["damage","roundsPerShot","rateOfFire","burstInterval","burstRounds","burstRateOfFire","chargeTime","clipSize","ammoMaximum","reloadTime","distributorDraw","thermalLoad","powerDraw","maximumRange","falloffRange","armourPiercing"];function weaponStatsFor(module,stats){if(!stats||stats.category!=="hardpoint")return null;const weapon={};for(const field of WEAPON_FIELDS){const value=effectiveStat(module,field,stats);if(value!==void 0)weapon[field]=value}normalizeEffectiveWeapon(module,weapon);const damageDistribution=effectiveDamageDistribution(module,stats);if(damageDistribution)weapon.damageDistribution=damageDistribution;if(stats.damageComponents&&!convertsDamage(module)){weapon.damageComponents=scaleDamageComponents(stats.damageComponents,stats.damage,typeof weapon.damage==="number"?weapon.damage:void 0)}if(stats.projectileRange)weapon.projectileRange={...stats.projectileRange};return weapon}function burstAdjustedRateOfFire(module,weapon){if(getLoadoutModifier(module,"RateOfFire")!==null)return void 0;const touched=["BurstSize","BurstRateOfFire","BurstInterval"].some(label=>getLoadoutModifier(module,label)!==null);if(!touched)return void 0;return combinedRateOfFire(weapon)}function normalizeEffectiveWeapon(module,weapon){const rate=burstAdjustedRateOfFire(module,weapon);if(rate!==void 0)weapon.rateOfFire=rate;const statedDamagePerSecond=getLoadoutModifier(module,"DamagePerSecond");const firingFactor=Number(weapon.roundsPerShot??1)*Number(weapon.rateOfFire??1);if(statedDamagePerSecond!==null&&firingFactor>0){weapon.damage=statedDamagePerSecond/firingFactor}const{maximumRange:maximumRange,falloffRange:falloffRange}=weapon;if(maximumRange!==void 0&&falloffRange!==void 0&&falloffRange>maximumRange){weapon.falloffRange=maximumRange}}var MILITARY_PREFIXES=["int_hullreinforcement","int_metaalloyhullreinforcement","int_modulereinforcement","int_shieldcellbank","int_guardianhullreinforcement","int_guardianmodulereinforcement","int_guardianshieldreinforcement"];var MINING_PREFIXES=["hpt_mininglaser","hpt_mining_abrblstr","hpt_mining_seismchrgwarhd","hpt_mining_subsurfdispmisle","hpt_human_extraction","hpt_miningtoolv2"];var CARGO_PREFIXES=["int_cargorack","int_largecargorack","int_corrosionproofcargorack","int_fueltank"];var RESTRICTED_SLOT_PREFIXES={mining:MINING_PREFIXES,military:MILITARY_PREFIXES,cargo:CARGO_PREFIXES,limpetController:["int_dronecontrol","int_multidronecontrol"],vesselHangar:["int_fighterbay"],passenger:["int_passengercabin","int_mkii_passengercabin"],planetaryApproachSuite:["int_planetapproachsuite"]};var problem=(constraint,message,params)=>({constraint:constraint,message:message,...params===void 0?{}:{params:params}});function restrictionProblem(slot,symbol){const restriction=slot.restriction;if(!restriction)return null;if(RESTRICTED_SLOT_PREFIXES[restriction].some(prefix=>symbol.startsWith(prefix))){return null}return problem("restrictedMount",`slot only takes ${SLOT_RESTRICTION_LABELS[restriction]}`,{restriction:restriction})}function moduleSlotProblem(slot,module){const required=module.restrictedToSlot;if(!required||slot.restriction===required)return null;return problem("restrictedMount",`module only fits a mount that takes ${SLOT_RESTRICTION_LABELS[required]}`,{restriction:required})}function moduleFitProblem(shipSymbol,slot,module){if(slot.kind==="cargoHatch"){return problem("immutableSlot","the cargoHatch slot cannot be changed")}if(slot.kind==="armour"){const hull=getShipBySymbol(shipSymbol);if(module.slot!=="armour"||module.ship===void 0){return problem("armourRequired","not a ship armour module")}if(!hull||module.ship.toLowerCase()!==hull.name.toLowerCase()){const armourHull=getShipByName(module.ship);return problem("wrongHullArmour",`armour belongs to ${truncate(module.ship)}, not ${truncate(hull?.name??shipSymbol)}`,{armourShipName:module.ship,...armourHull===null?{}:{armourShipSymbol:armourHull.symbol},shipSymbol:shipSymbol,...hull===null?{}:{shipName:hull.name}})}return null}const restricted=module.restrictedToShips;if(restricted&&!restricted.some(symbol2=>symbol2.toLowerCase()===shipSymbol.toLowerCase())){const allowedShipNames=restricted.map(symbol2=>{const hull=getShipBySymbol(symbol2);return hull?.name??symbol2});const labels=restricted.map((symbol2,index)=>{const name=allowedShipNames[index];return name===symbol2?symbol2:`${name} (${symbol2})`});return problem("restrictedHull",`module is restricted to ${truncate(labels.join(", "))}`,{allowedShipNames:allowedShipNames,allowedShipSymbols:[...restricted],shipSymbol:shipSymbol})}const wrongMount=moduleSlotProblem(slot,module);if(wrongMount)return wrongMount;const symbol=module.symbol.toLowerCase();const moduleSlot=module.slot;switch(slot.kind){case"core":if(moduleSlot!==slot.core){return problem("wrongCoreType",`not a ${slot.core} module`,{requiredCore:slot.core,moduleSlot:moduleSlot??"none"})}break;case"hardpoint":{if(module.category!=="hardpoint"){return problem("hardpointRequired","not a hardpoint weapon")}const restricted2=restrictionProblem(slot,symbol);if(restricted2)return restricted2;break}case"utility":if(module.category!=="utility"){return problem("utilityRequired","not a utility module")}return null;case"optional":{const isFuelTank=moduleSlot==="fuelTank";if(module.category!=="internal"&&!isFuelTank){return problem("optionalInternalRequired","not an optional-internal module")}if(moduleSlot&&!isFuelTank){return problem("coreModuleInOptionalSlot","a core module only fits its core slot")}const restricted2=restrictionProblem(slot,symbol);if(restricted2)return restricted2;break}}return module.class>slot.size?problem("oversized",`module size ${truncate(module.class)} exceeds slot size ${slot.size}`,{moduleClass:module.class,slotSize:slot.size}):null}function moduleFitError(shipSymbol,slot,module){return moduleFitProblem(shipSymbol,slot,module)?.message??null}var REBUY_FRACTION=.05;function exportLoadoutEvent(input,options){const fromSource=options.credits==="source";const source=fromSource?input.sourcePurchase:null;const totals=source!==null&&sourceTotalsHold(input.modules,source)?source:null;const hullValue=fromSource?source?.hullValue??null:input.retailHullValue;const modulesValue=fromSource?totals?.modulesValue??null:computedModulesValue(input.modules,input.statsFor);const rebuy=fromSource?totals?.rebuy??null:hullValue===null||modulesValue===null?null:Math.trunc((hullValue+modulesValue)*REBUY_FRACTION);return{event:"Loadout",Ship:input.shipSymbol.toLowerCase(),...input.shipName===void 0?{}:{ShipName:input.shipName},...input.shipIdent===void 0?{}:{ShipIdent:input.shipIdent},...hullValue===null?{}:{HullValue:hullValue},...modulesValue===null?{}:{ModulesValue:modulesValue},...input.unladenMass===null?{}:{UnladenMass:input.unladenMass},...input.cargoCapacity===null?{}:{CargoCapacity:input.cargoCapacity},...input.maxJumpRange===null?{}:{MaxJumpRange:input.maxJumpRange},...input.fuelCapacity===null?{}:{FuelCapacity:{Main:input.fuelCapacity.main,Reserve:input.fuelCapacity.reserve}},...rebuy===null?{}:{Rebuy:rebuy},Modules:exportModules(input,options,fromSource)}}function exportModules(input,options,fromSource){const ordered=options.moduleOrder==="slots"?slotOrderedModules(input.modules,input.layout):[...input.modules.values()];return ordered.map(module=>{const on=module.On??(options.explicitPower?true:void 0);const priority=module.Priority??(options.explicitPower?0:void 0);const value=fromSource?sourceModuleValue(module,input.sourcePurchase):moduleValue(module,input.statsFor);return{Slot:module.Slot,Item:module.Item.toLowerCase(),...on===void 0?{}:{On:on},...priority===void 0?{}:{Priority:priority},...module.Health===void 0?{}:{Health:module.Health},...typeof value==="number"?{Value:value}:{},...module.Engineering===void 0?{}:{Engineering:cloneLoadoutModule(module).Engineering}}})}function slotOrderedModules(modules,layout){return orderBySlotLayout([...modules.values()],layout,module=>module.Slot)}function computedModulesValue(modules,statsFor){let sum=0;for(const module of modules.values()){const value=moduleValue(module,statsFor);if(value==="unknown")return null;if(value!=="free")sum+=value}return sum}function moduleValue(module,statsFor){const stats=statsFor(module);if(stats!==null)return stats.cost??"unknown";return isNonOutfittingSlot(module.Slot)||isBuiltInHullModule(module)?"free":"unknown"}var SOURCE_ITEM="ShipLoadout: sourcePurchase moduleValues[].item";function sourceModuleValue(module,source){const entry=source===null?null:getSourceModuleValue(source,module.Slot);if(entry===null)return"unknown";return normalizeKey(entry.item,SOURCE_ITEM)===normalizeKey(module.Item,FITTED_ITEM)?entry.value:"unknown"}function sourceTotalsHold(modules,source){for(const entry of source.moduleValues){const key=matchingKeyIn(modules,entry.slot);const fitted=key===null?void 0:modules.get(key);if(!fitted)return false;if(isCargoHatchSlot(entry.slot)&&entry.value===0)continue;if(normalizeKey(fitted.Item,FITTED_ITEM)!==normalizeKey(entry.item,SOURCE_ITEM)){return false}}return true}function captureLoadoutEvent(event){const modules=event.Modules;const shipName=event.ShipName;const shipIdent=event.ShipIdent;const hullValue=event.HullValue;const modulesValue=event.ModulesValue;const rebuy=event.Rebuy;const unladenMass=event.UnladenMass;const cargoCapacity=event.CargoCapacity;const fuelCapacity=event.FuelCapacity;return{Ship:event.Ship,Modules:Array.isArray(modules)?captureEach(modules,captureModule):modules,...shipName===void 0?{}:{ShipName:shipName},...shipIdent===void 0?{}:{ShipIdent:shipIdent},...hullValue===void 0?{}:{HullValue:hullValue},...modulesValue===void 0?{}:{ModulesValue:modulesValue},...rebuy===void 0?{}:{Rebuy:rebuy},...unladenMass===void 0?{}:{UnladenMass:unladenMass},...cargoCapacity===void 0?{}:{CargoCapacity:cargoCapacity},...fuelCapacity===void 0?{}:{FuelCapacity:{...fuelCapacity}}}}function captureEach(values,capture){const captured=[];const{length:length}=values;for(let index=0;index<length;index++)captured.push(capture(values[index]));return captured}function captureModule(module){if(module===null||typeof module!=="object")return module;const on=module.On;const priority=module.Priority;const health=module.Health;const value=module.Value;const engineering=module.Engineering;return{Slot:module.Slot,Item:module.Item,...on===void 0?{}:{On:on},...priority===void 0?{}:{Priority:priority},...health===void 0?{}:{Health:health},...value===void 0?{}:{Value:value},...engineering===void 0?{}:{Engineering:captureEngineering(engineering)}}}function captureEngineering(engineering){if(engineering===null||typeof engineering!=="object")return engineering;const experimental=engineering.ExperimentalEffect;const experimentalLocalised=engineering.ExperimentalEffect_Localised;const modifiers=engineering.Modifiers;return{BlueprintName:engineering.BlueprintName,Level:engineering.Level,Quality:engineering.Quality,...experimental===void 0?{}:{ExperimentalEffect:experimental},...experimentalLocalised===void 0?{}:{ExperimentalEffect_Localised:experimentalLocalised},...modifiers===void 0?{}:{Modifiers:Array.isArray(modifiers)?captureEach(modifiers,modifier=>modifier!==null&&typeof modifier==="object"?{...modifier}:modifier):modifiers}}}function normalizeLoadoutEvent(rawEvent){const event=captureLoadoutEvent(rawEvent);requireString(event.Ship,"ShipLoadout.fromLoadout: event.Ship");if(!Array.isArray(event.Modules)){throw new TypeError(`ShipLoadout.fromLoadout: event.Modules must be an array, received ${describeValue(event.Modules)}`)}const modules=/* @__PURE__ */new Map;const slots=/* @__PURE__ */new Set;for(const module of event.Modules){if(module===null||typeof module!=="object"){throw new TypeError(`ShipLoadout.fromLoadout: event.Modules[] must hold module objects, received ${describeValue(module)}`)}requireString(module.Slot,"ShipLoadout.fromLoadout: module.Slot");requireString(module.Item,"ShipLoadout.fromLoadout: module.Item");if(module.Engineering!==void 0){if(module.Engineering===null||typeof module.Engineering!=="object"){throw new TypeError(`ShipLoadout.fromLoadout: module.Engineering must be an object, received ${describeValue(module.Engineering)}`)}requireStringIfPresent(module.Engineering.BlueprintName,"ShipLoadout.fromLoadout: module.Engineering.BlueprintName");requireStringIfPresent(module.Engineering.ExperimentalEffect,"ShipLoadout.fromLoadout: module.Engineering.ExperimentalEffect");if(module.Engineering.Modifiers!==void 0&&!Array.isArray(module.Engineering.Modifiers)){throw new TypeError(`ShipLoadout.fromLoadout: module.Engineering.Modifiers must be an array, received ${describeValue(module.Engineering.Modifiers)}`)}for(const[index,modifier]of(module.Engineering.Modifiers??[]).entries()){if(modifier===null||typeof modifier!=="object"){throw new TypeError(`ShipLoadout.fromLoadout: module.Engineering.Modifiers[${index}] must be an object, received ${describeValue(modifier)}`)}requireString(modifier.Label,`ShipLoadout.fromLoadout: module.Engineering.Modifiers[${index}].Label`)}}const normalizedSlot=module.Slot.toLowerCase();if(slots.has(normalizedSlot)){throw new TypeError(`ShipLoadout.fromLoadout: duplicate slot "${truncate(module.Slot)}"`)}slots.add(normalizedSlot);modules.set(module.Slot,cloneLoadoutModule(module))}const top={};if(event.ShipName!==void 0)top.ShipName=event.ShipName;if(event.ShipIdent!==void 0)top.ShipIdent=event.ShipIdent;if(event.HullValue!==void 0)top.HullValue=event.HullValue;if(event.ModulesValue!==void 0)top.ModulesValue=event.ModulesValue;if(event.Rebuy!==void 0)top.Rebuy=event.Rebuy;if(event.UnladenMass!==void 0)top.UnladenMass=event.UnladenMass;if(event.CargoCapacity!==void 0)top.CargoCapacity=event.CargoCapacity;if(event.FuelCapacity!==void 0)top.FuelCapacity={...event.FuelCapacity};const moduleStats=/* @__PURE__ */new Map;const primitiveModifiers=/* @__PURE__ */new Map;for(const module of modules.values()){const engineering=module.Engineering;const variant=identifyPreEngineeredVariant(module);const catalogueVariantStats=variant?getPreEngineeredStats(variant):null;let variantStats=catalogueVariantStats;const retainsBakedExperimental=variant?.experimental!==void 0&&typeof engineering?.ExperimentalEffect==="string"&&variant.experimental.trim().toLowerCase()===engineering.ExperimentalEffect.trim().toLowerCase();if(variant&&catalogueVariantStats&&!catalogueVariantStats.engineeringLocked&&!retainsBakedExperimental){const{experimental:originalExperimental,...withoutExperimental}=variant;const currentExperimental=engineering?.ExperimentalEffect;const currentVariant=typeof currentExperimental==="string"?{...withoutExperimental,experimental:currentExperimental}:withoutExperimental;variantStats=getPreEngineeredStats(withoutExperimental);primitiveModifiers.set(module.Slot,[...engineering?.Modifiers??[],...getPreEngineeredModifiers(currentVariant)])}if(variantStats)moduleStats.set(module.Slot,cloneModuleStats(variantStats));const guardianFinal=typeof engineering?.BlueprintName==="string"&&isFinalGuardianWeaponEngineering(module.Item,engineering.BlueprintName);if(variantStats?.engineeringLocked||typeof engineering?.BlueprintName!=="string"||!guardianFinal){continue}const normalizedBlueprint=normalizeKey(engineering.BlueprintName,"ShipLoadout.fromLoadout: module.Engineering.BlueprintName");const normalizedExperimental=normalizeKey(engineering.ExperimentalEffect,"ShipLoadout.fromLoadout: module.Engineering.ExperimentalEffect");const variants=getPreEngineeredVariants(module.Item);const exact=variants.find(candidate=>candidate.engineeringLocked===true&&candidate.blueprint.toLowerCase()===normalizedBlueprint&&candidate.grade===engineering.Level&&candidate.experimental?.toLowerCase()===normalizedExperimental);const guardianBase=variants.find(candidate=>candidate.engineeringLocked===true&&candidate.blueprint.toLowerCase()===normalizedBlueprint&&candidate.grade===engineering.Level&&candidate.experimental===void 0);const stats=exact?getPreEngineeredStats(exact):guardianBase&&engineering.ExperimentalEffect!==void 0?getPreEngineeredStats({...guardianBase,experimental:engineering.ExperimentalEffect}):builtInModuleBySymbol(module.Item,"ShipLoadout.fromLoadout: module.Item");if(stats){moduleStats.set(module.Slot,cloneModuleStats({...stats,engineeringLocked:true}))}}return{shipSymbol:event.Ship,modules:modules,moduleStats:moduleStats,primitiveModifiers:primitiveModifiers,top:top,sourcePurchase:sourcePurchaseFromLoadout(event)}}var SLOT_KEY="ShipLoadout: slotKey";var requireLoadOptions=(scope,options)=>{for(const field of["fuel","cargo"]){const value=options[field];if(value!==void 0&&(!Number.isFinite(value)||value<0)){throw new RangeError(`${scope}: ${field} must be a finite non-negative number`)}}};var requireEnginesPips=(scope,enginesPips)=>{if(!Number.isFinite(enginesPips)||enginesPips<0||enginesPips>4){throw new RangeError(`${scope}: enginesPips must be a finite number from 0 to 4`)}return enginesPips};var requireSystemsPips=(scope,systemsPips)=>{if(!Number.isFinite(systemsPips)||systemsPips<0||systemsPips>4){throw new RangeError(`${scope}: systemsPips must be a finite number from 0 to 4`)}return systemsPips};var LoadoutEditError=class extends TypeError{code;constraint;params;constructor(message,code,params,constraint){super(message);this.code=code;this.params=deepFreeze(structuredClone(params));if(constraint!==void 0)this.constraint=constraint}};var experimentalEffectUnsupported=(code,params)=>deepFreeze({kind:"unsupported",code:code,params:params});var engineeringNormalizationUnsupported=(code,params)=>deepFreeze({kind:"unsupported",code:code,params:params});var FSD_PREFIX="int_hyperdrive";var BOOSTER_PREFIX="int_guardianfsdbooster";var FUEL_TANK_PREFIX="int_fueltank";var ShipLoadout=class _ShipLoadout{#ship;#shipSymbol;#modules;#moduleStats;#primitiveModifiers;#top;#sourcePurchase;#slotCache=/* @__PURE__ */new Map;#layoutCache;constructor(ship,shipSymbol,modules,top,sourcePurchase=null,moduleStats=/* @__PURE__ */new Map,primitiveModifiers=/* @__PURE__ */new Map){this.#ship=ship;this.#shipSymbol=shipSymbol;this.#modules=modules;this.#top=top;this.#sourcePurchase=sourcePurchase;this.#moduleStats=moduleStats;this.#primitiveModifiers=primitiveModifiers}static fromSlef(input,index=0){const entries=parseSlef(input);const entry=entries[index];if(!entry){throw new TypeError(`ShipLoadout.fromSlef: no entry at index ${truncate(index)} (have ${entries.length})`)}const imported=normalizeLoadoutEvent(entry.data);const ship=getShipBySymbol(imported.shipSymbol);if(!ship){throw new TypeError(`ShipLoadout.fromSlef: unknown hull "${truncate(imported.shipSymbol)}"`)}return _ShipLoadout.#fromImported(imported,ship)}static fromLoadout(event){if(event===null||typeof event!=="object"){throw new TypeError(`ShipLoadout.fromLoadout: event must be a Loadout event, received ${describeValue(event)}`)}const imported=normalizeLoadoutEvent(event);const ship=getShipBySymbol(imported.shipSymbol);if(!ship){throw new TypeError(`ShipLoadout.fromLoadout: unknown hull "${truncate(imported.shipSymbol)}"`)}return _ShipLoadout.#fromImported(imported,ship)}static#fromImported(imported,ship){const defaultHatch=getDefaultLoadout(imported.shipSymbol)?.modules.find(module=>isCargoHatchSlot(module.slot));const capturedHatchKey=defaultHatch===void 0?null:matchingKeyIn(imported.modules,defaultHatch.slot);const capturedHatch=capturedHatchKey===null?void 0:imported.modules.get(capturedHatchKey);if(defaultHatch&&capturedHatch===void 0){const ownSlot=ownKeyIn(imported.modules,defaultHatch.slot);imported.modules.set(ownSlot,{Slot:ownSlot,Item:defaultHatch.symbol})}const build=new _ShipLoadout(ship,imported.shipSymbol,imported.modules,imported.top,imported.sourcePurchase,imported.moduleStats,imported.primitiveModifiers);if(capturedHatch!==void 0&&!isBuiltInHullModule(capturedHatch)){build.repairFixedMount(capturedHatch.Slot)}return build}static empty(shipSymbol){const requested=requireString(shipSymbol,"ShipLoadout.empty: shipSymbol");const ship=getShipBySymbol(requested);if(!ship){throw new TypeError(`ShipLoadout.empty: no slot layout for hull "${truncate(shipSymbol)}"`)}const hatch=getDefaultLoadout(ship.symbol)?.modules.find(module=>isCargoHatchSlot(module.slot));const modules=/* @__PURE__ */new Map;if(hatch){modules.set(hatch.slot,{Slot:hatch.slot,Item:hatch.symbol})}return new _ShipLoadout(ship,ship.symbol,modules,{})}static default(shipSymbol){const requested=requireString(shipSymbol,"ShipLoadout.default: shipSymbol");const ship=getShipBySymbol(requested);if(!ship){throw new TypeError(`ShipLoadout.default: no default loadout for hull "${truncate(shipSymbol)}"`)}const loadout=getDefaultLoadout(ship.symbol);return new _ShipLoadout(ship,loadout.symbol,new Map(loadout.modules.map(module=>[module.slot,{Slot:module.slot,Item:module.symbol}])),{})}get shipSymbol(){return this.#shipSymbol}get shipName(){return this.#top.ShipName??null}get shipIdent(){return this.#top.ShipIdent??null}get unladenMass(){return this.unladenMassResult.value}get unladenMassResult(){return this.#top.UnladenMass===void 0?this.#computedUnladenMass():completeResult(this.#top.UnladenMass)}#computedUnladenMass(){return calculateUnladenMass(this.#ship.hullMass,this.#calculationModules())}get fuelCapacity(){return this.fuelCapacityResult.value}get fuelCapacityResult(){const cap=this.#top.FuelCapacity;if(cap?.Main!==void 0&&cap.Reserve!==void 0){return completeResult(Object.freeze({main:cap.Main,reserve:cap.Reserve}))}const computed=this.#computedFuelCapacity();if(computed.value===null)return computed;return completeResult(Object.freeze({main:cap?.Main??computed.value.main,reserve:cap?.Reserve??computed.value.reserve}))}get cargoCapacity(){return this.cargoCapacityResult.value}get cargoCapacityResult(){return this.#top.CargoCapacity===void 0?this.#computedCargoCapacity():completeResult(this.#top.CargoCapacity)}#computedCargoCapacity(){return calculateCargoCapacity(this.#calculationModules())}#computedFuelCapacity(){return calculateFuelCapacity(this.#ship.reserveFuelCapacity,this.#calculationModules())}get hullValue(){return this.#top.HullValue??null}get modulesValue(){return this.#top.ModulesValue??null}get rebuy(){return this.#top.Rebuy??null}get sourcePurchase(){return this.#sourcePurchase}get validation(){const slots=this.#layout();const byKey=new Map(slots.map(slot=>[slot.key.toLowerCase(),slot]));const modules=[...this.#modules.values()].map(module=>{const stats=this.#statsFor(module);const slot=byKey.get(module.Slot.toLowerCase());const builtIn=stats===null&&isNonOutfittingSlot(module.Slot)||isBuiltInHullModule(module);const fitProblem=stats&&slot&&!builtIn?moduleFitProblem(this.#shipSymbol,slot,stats):null;return{slot:module.Slot,symbol:module.Item,known:stats!==null||builtIn,requiresKnownSlot:!builtIn,fitError:fitProblem?.message??null,...fitProblem===null?{}:{fitConstraint:fitProblem.constraint},...fitProblem?.params===void 0?{}:{fitParams:fitProblem.params},...stats?.exclusionGroup===void 0?{}:{exclusionGroup:stats.exclusionGroup},...stats?.limitGroup===void 0?{}:{limitGroup:stats.limitGroup},...stats?.limitIncrease===void 0?{}:{limitIncrease:stats.limitIncrease}}});return validateLoadout({shipSymbol:this.#shipSymbol,slots:slots,modules:modules})}slots(kind){const cached=this.#slotCache.get(kind);if(cached!==void 0)return cached;const slots=kind===void 0?this.#layout():this.#layout().filter(slot=>slot.kind===kind);const currentLimits=this.#moduleLimits();const value=deepFreeze(slots.map(slot=>{const stats=this.#moduleStatsAt(slot.key);const fixedReason=fixedSlotReason(slot);const immovableReason=fixedReason!==null?fixedReason:stats?.limitIncrease!==void 0&&this.#moduleLimitRegression(slot.key,null,currentLimits,stats)!==null?"moduleLimit":null;return{...slot,name:loadoutSlotName(slot),module:this.fittedModuleAt(slot.key),removable:immovableReason===null,...immovableReason===null?{}:{immovableReason:immovableReason}}}));this.#slotCache.set(kind,value);return value}fittedModuleAt(slotKey){const module=this.#fittedModuleFor(slotKey);if(!module)return null;const raw=cloneLoadoutModule(module);const stats=this.#statsFor(module);const effective=effectiveModule(this.#moduleForEffectiveStats(module),stats);return deepFreeze({slot:module.Slot,symbol:raw.Item,on:raw.On,priority:raw.Priority,health:raw.Health,value:raw.Value,engineering:raw.Engineering,raw:raw,stats:stats===null?null:cloneModuleStats(stats),effectiveStats:effective===null?null:cloneModuleStats(effective),ammunition:ammunitionCapacity(effective),preEngineeredVariant:identifyPreEngineeredVariant(raw)})}fittedModules(){return deepFreeze([...this.#modules.keys()].flatMap(key=>{const fitted=this.fittedModuleAt(key);return fitted===null?[]:[fitted]}))}availableBlueprints(slotKey){const module=this.#fittedModuleFor(slotKey);return deepFreeze(module?availableBlueprintsFor(module.Item,this.#statsFor(module)):[])}availableExperimentalEffects(slotKey){const module=this.#fittedModuleFor(slotKey);return deepFreeze(module?availableExperimentalsFor(module.Item,this.#statsFor(module)):[])}modulesForSlot(slotKey){const slot=this.#requireSlot(slotKey);const occupied=new Set([...this.#modules.values()].flatMap(fitted=>{if(fitted.Slot.toLowerCase()===slot.key.toLowerCase())return[];const group=this.#statsFor(fitted)?.exclusionGroup;return group===void 0?[]:[group]}));const currentLimits=this.#moduleLimits();const currentStats=this.#moduleStatsAt(slot.key);return ALL_MODULES.filter(module=>moduleFitError(this.#shipSymbol,slot,module)===null&&(module.exclusionGroup===void 0||!occupied.has(module.exclusionGroup))&&this.#moduleLimitRegression(slot.key,module,currentLimits,currentStats)===null)}repairFixedMount(slotKey){const requested=requireString(slotKey,SLOT_KEY);const wanted=requested.toLowerCase();const slot=this.#requireSlot(requested);const fittedKey=this.#fittedKey(requested);const resultSlot=fittedKey??requested;const canonicalKey=slot.key;if(fixedSlotReason(slot)===null){return deepFreeze({status:"refused",slot:resultSlot,reason:"notFixedMount"})}const current=this.#fittedModuleFor(requested);const currentStats=current?this.#statsFor(current):null;const valid=current!==void 0&&currentStats!==null&&(slot.kind==="cargoHatch"?isBuiltInHullModule(current):moduleFitProblem(this.#shipSymbol,slot,currentStats)===null);if(valid){return deepFreeze({status:"unchanged",slot:current.Slot,symbol:current.Item})}const defaultModule=getDefaultLoadout(this.#shipSymbol)?.modules.find(module=>module.slot.toLowerCase()===wanted);if(!defaultModule){return deepFreeze({status:"defaultUnavailable",slot:resultSlot})}const ownKey=ownKeyIn(this.#modules,canonicalKey);const replacement={Slot:ownKey,Item:defaultModule.symbol,...current?.On===void 0?{}:{On:current.On},...current?.Priority===void 0?{}:{Priority:current.Priority},...current?.Health===void 0?{}:{Health:current.Health}};const replacementStats=builtInModuleBySymbol(defaultModule.symbol,"ShipLoadout.repairFixedMount")??(isBuiltInHullModule(replacement)?builtInModuleBySymbol("ModularCargoBayDoor","ShipLoadout.repairFixedMount"):null);if(!replacementStats){return deepFreeze({status:"defaultUnavailable",slot:resultSlot,symbol:defaultModule.symbol})}this.#replaceModule(ownKey,replacement,replacementStats);return deepFreeze({status:"repaired",slot:ownKey,symbol:defaultModule.symbol})}setModule(slotKey,module){const slot=this.#requireSlot(slotKey);if(module===null||module===void 0){throw new TypeError(`ShipLoadout.setModule: no module supplied for "${truncate(slotKey)}" (did the module lookup return undefined?)`)}if(typeof module.symbol!=="string"){throw new TypeError(`ShipLoadout.setModule: module for "${truncate(slotKey)}" must be an outfitting module, received ${describeValue(module)}`)}const problem2=moduleFitProblem(this.#shipSymbol,slot,module);if(problem2){if(problem2.constraint==="immutableSlot"){throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${problem2.message}`,"immutableSlot",{slot:slot.key})}throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${problem2.message}`,"incompatibleModule",{...problem2.params,slot:slot.key,symbol:module.symbol,constraint:problem2.constraint},problem2.constraint)}if(module.exclusionGroup!==void 0){const conflict=[...this.#modules.values()].find(fitted=>fitted.Slot.toLowerCase()!==slot.key.toLowerCase()&&this.#statsFor(fitted)?.exclusionGroup===module.exclusionGroup);if(conflict){throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${module.exclusionGroup} is limited to one per ship (already fitted in ${truncate(conflict.Slot)})`,"duplicateExclusiveModule",{exclusionGroup:module.exclusionGroup,slot:slot.key,symbol:module.symbol,previousSlot:conflict.Slot,previousSymbol:conflict.Item})}}const limitProblem=this.#moduleLimitRegression(slot.key,module);if(limitProblem!==null){throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${limitProblem.group} would have ${limitProblem.count} modules but the ship allows ${limitProblem.limit}`,"moduleLimitExceeded",{group:limitProblem.group,count:limitProblem.count,limit:limitProblem.limit,slot:slot.key,symbol:module.symbol})}const key=this.#fittedKey(slotKey)??slot.key;this.#replaceModule(key,{Slot:key,Item:module.symbol},cloneModuleStats(module));return this}removeModule(slotKey){const wanted=requireString(slotKey,SLOT_KEY).toLowerCase();if(wanted==="cargohatch"){throw new LoadoutEditError("ShipLoadout.removeModule: the cargoHatch slot cannot be changed","immutableSlot",{slot:"CargoHatch"})}const parsed=parseSlotName(slotKey);const slot=this.#layout().find(candidate=>candidate.key.toLowerCase()===wanted);if(parsed!==null&&fixedSlotReason(parsed)==="requiredSlot"){const fittedKey=this.#fittedKey(slotKey);const key2=slot?.key??fittedKey??slotKey;throw new LoadoutEditError(`ShipLoadout.removeModule: the ${truncate(key2)} slot is required and cannot be emptied`,"requiredSlot",{slot:key2})}const key=this.#fittedKey(slotKey);if(key!==null){const limitProblem=this.#moduleLimitRegression(key,null);if(limitProblem!==null){const fitted=this.#modules.get(key);throw new LoadoutEditError(`ShipLoadout.removeModule: ${truncate(slotKey)}: ${limitProblem.group} would have ${limitProblem.count} modules but the ship allows ${limitProblem.limit}`,"moduleLimitExceeded",{group:limitProblem.group,count:limitProblem.count,limit:limitProblem.limit,slot:key,...fitted===void 0?{}:{symbol:fitted.Item}})}this.#replaceModule(key,null)}return this}applyBlueprint(slotKey,fdname,options){requireString(fdname,"ShipLoadout.applyBlueprint: fdname");if(options===null||typeof options!=="object"){throw new TypeError(`ShipLoadout.applyBlueprint: options must be an object with a grade, received ${describeValue(options)}`)}const wantedGrade=options.grade;const wantedQuality=options.quality;const wantedExperimental=options.experimental??void 0;requireStringIfPresent(wantedExperimental,"ShipLoadout.applyBlueprint: options.experimental");const module=this.#fittedModuleFor(slotKey);if(!module){throw new RangeError(`ShipLoadout.applyBlueprint: slot "${truncate(slotKey)}" is empty`)}const fittedStats=this.#statsFor(module);if(!fittedStats){throw new TypeError(`ShipLoadout.applyBlueprint: no stats for module "${truncate(module.Item)}"`)}const recipe=resolveBlueprintForModule(module.Item,fdname);const named=recipe===fdname?`"${truncate(fdname)}"`:`"${truncate(fdname)}" (${truncate(recipe)} on this module)`;const written=fdname.trim().toLowerCase();const resolved=recipe.trim().toLowerCase();if(getPreEngineeredVariants(module.Item).some(variant=>variant.acquisition==="eventReward"&&(variant.blueprint.toLowerCase()===written||variant.blueprint.toLowerCase()===resolved))){throw new TypeError(`ShipLoadout.applyBlueprint: ${named} is a fixed pre-engineered identity, not a craftable blueprint; use setPreEngineeredVariant to fit its fixed article`)}if(!Number.isInteger(wantedGrade)||wantedGrade<1||wantedGrade>5){throw new RangeError(`ShipLoadout.applyBlueprint: no blueprint ${named} grade ${truncate(wantedGrade)}`)}const grade=getBlueprintGrade(recipe,wantedGrade);if(!grade){throw new RangeError(`ShipLoadout.applyBlueprint: no blueprint ${named} grade ${truncate(wantedGrade)}`)}let experimental;if(wantedExperimental!==void 0){experimental=getExperimentalEffect(wantedExperimental);if(!experimental){throw new RangeError(`ShipLoadout.applyBlueprint: unknown experimental effect "${truncate(wantedExperimental)}"`)}}const quality=wantedQuality??1;if(!Number.isFinite(quality)||quality<0||quality>1){throw new RangeError(`ShipLoadout.applyBlueprint: quality must be a finite number in [0, 1]`)}if(fittedStats.engineeringLocked){throw new TypeError(`ShipLoadout.applyBlueprint: module "${truncate(module.Item)}" is a final pre-engineered article and accepts no further engineering`)}if(!blueprintAvailableFor(module.Item,fdname)){const offered=[...blueprintRoutesFor(module.Item)].map(([blueprint,route])=>`${blueprint} (${route})`);throw new TypeError(offered.length>0?`ShipLoadout.applyBlueprint: module "${truncate(module.Item)}" is not offered blueprint ${named}; available candidates are ${offered.join(", ")}`:`ShipLoadout.applyBlueprint: no registry lists an engineering menu for module "${truncate(module.Item)}"`)}if(wantedExperimental!==void 0&&!experimentalAvailableFor(module.Item,wantedExperimental)){const offered=getExperimentalsForModule(module.Item);throw new TypeError(`ShipLoadout.applyBlueprint: module "${truncate(module.Item)}" is not offered experimental effect "${truncate(wantedExperimental)}"; it takes ${offered.length>0?offered.join(", "):"no experimental effect"}`)}const stats=this.#engineeringBaseStats(module)??fittedStats;const base=baseStats(stats);const canonical=primitiveEngineeringInputsFor(stats,grade,experimental);const missing=missingBaseLabels(stats,base,canonical.grade.features,canonical.experimental?.modifiers);if(missing.length>0){throw new TypeError(`ShipLoadout.applyBlueprint: cannot compute ${named} for module "${truncate(module.Item)}"; missing base stats for ${missing.join(", ")}`)}const damageDistribution=experimental?.damageDistribution??grade.damageDistribution;const primitiveModifiers=computeModifiers(base,canonical.grade,quality,canonical.experimental);const modifiers=journalModifiersFor(stats,primitiveModifiers);if(damageDistribution){for(const type of["kinetic","thermal","explosive","absolute"]){const value=damageDistribution[type];if(value===void 0)continue;const label=labelsForDamageType(type)[0];if(label===void 0)continue;const damageModifier={Label:label,Value:value*scaleForLabel(label),OriginalValue:(stats.damageDistribution?.[type]??0)*scaleForLabel(label)};modifiers.push(damageModifier);primitiveModifiers.push(damageModifier)}}const engineering={BlueprintName:fdname,Level:wantedGrade,Quality:quality,...wantedExperimental!==void 0?{ExperimentalEffect:wantedExperimental}:{},Modifiers:modifiers};this.#replaceModule(module.Slot,{...module,Engineering:engineering},stats,primitiveModifiers);return this}setExperimentalEffect(slotKey,experimental){if(experimental!==null){requireString(experimental,"ShipLoadout.setExperimentalEffect: experimental")}const wanted=experimental;const module=this.#fittedModuleFor(slotKey);if(!module)return experimentalEffectUnsupported("emptySlot",{slot:slotKey});const stats=this.#statsFor(module);if(!stats){return experimentalEffectUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const engineering=module.Engineering;if(!engineering){return experimentalEffectUnsupported("notEngineered",{slot:module.Slot,symbol:module.Item})}if(stats.engineeringLocked){return experimentalEffectUnsupported("finalArticle",{slot:module.Slot,symbol:module.Item})}const previous=engineering.ExperimentalEffect??null;if(previous===null&&wanted===null||previous!==null&&wanted!==null&&previous.trim().toLowerCase()===wanted.trim().toLowerCase()){return deepFreeze({kind:"unchanged",experimental:previous})}const variant=identifyPreEngineeredVariant(module);let effect;if(wanted!==null){effect=getExperimentalEffect(wanted);if(!effect){return experimentalEffectUnsupported("unknownExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:wanted})}const restoresBakedEffect=variant?.experimental!==void 0&&variant.experimental.trim().toLowerCase()===wanted.trim().toLowerCase();if(!experimentalAvailableFor(module.Item,wanted)&&!restoresBakedEffect){return experimentalEffectUnsupported("unsupportedExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:wanted})}}if(variant&&variant.acquisition!=="mercenary"){const stock=this.#engineeringBaseStats(module);if(!stock){return experimentalEffectUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const missing=missingBaseLabels(stock,baseStats(stock),[],effect?.modifiers);if(missing.length>0){return experimentalEffectUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}const{experimental:originalEffect,...withoutEffect}=variant;const adjusted=wanted===null?withoutEffect:{...withoutEffect,experimental:wanted};const resolved=getPreEngineeredStats(withoutEffect);if(!resolved){return experimentalEffectUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const replacement={BlueprintName:engineering.BlueprintName,Level:engineering.Level,Quality:engineering.Quality,...wanted===null?{}:{ExperimentalEffect:wanted},Modifiers:getPreEngineeredJournalModifiers(adjusted)};this.#replaceModule(module.Slot,{...module,Engineering:replacement},cloneModuleStats(resolved),getPreEngineeredModifiers(adjusted))}else{const blueprint=engineering.BlueprintName;const grade=engineering.Level;const quality=engineering.Quality;if(typeof blueprint!=="string"||!Number.isInteger(grade)||grade<1||grade>5){return experimentalEffectUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const currentEffect=previous===null?void 0:getExperimentalEffect(previous)??null;if(ordinaryEngineeringProof(module.Item,engineering,currentEffect)==="unproven"){return experimentalEffectUnsupported("unidentifiedPreEngineeredVariant",{slot:module.Slot,symbol:module.Item,blueprint:blueprint})}const recipe=resolveBlueprintForModule(module.Item,blueprint);const blueprintGrade=getBlueprintGrade(recipe,grade);if(!blueprintGrade||!blueprintAvailableFor(module.Item,blueprint)||!Number.isFinite(quality)||quality<0||quality>1){return experimentalEffectUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item,blueprint:blueprint,grade:grade})}const base=this.#engineeringBaseStats(module)??stats;const canonical=primitiveEngineeringInputsFor(base,blueprintGrade,effect);const missing=missingBaseLabels(base,baseStats(base),canonical.grade.features,canonical.experimental?.modifiers);if(missing.length>0){return experimentalEffectUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}this.applyBlueprint(module.Slot,blueprint,{grade:grade,quality:quality,...wanted===null?{}:{experimental:wanted}})}return deepFreeze({kind:"updated",previousExperimental:previous,experimental:wanted})}completeEngineeringGrade(slotKey){const module=this.#fittedModuleFor(slotKey);if(!module)return engineeringNormalizationUnsupported("emptySlot",{slot:slotKey});const stats=this.#statsFor(module);if(!stats){return engineeringNormalizationUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const engineering=module.Engineering;if(!engineering){return engineeringNormalizationUnsupported("notEngineered",{slot:module.Slot,symbol:module.Item})}if(stats.engineeringLocked){return engineeringNormalizationUnsupported("finalArticle",{slot:module.Slot,symbol:module.Item})}if(engineering.Quality===1){return deepFreeze({kind:"unchanged"})}const previousQuality=engineering.Quality;if(!Number.isFinite(previousQuality)||previousQuality<0||previousQuality>1){return engineeringNormalizationUnsupported("invalidQuality",{slot:module.Slot,symbol:module.Item})}const experimental=engineering.ExperimentalEffect??null;const effect=experimental===null?void 0:getExperimentalEffect(experimental)??void 0;if(experimental!==null&&!effect){return engineeringNormalizationUnsupported("unknownExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:experimental})}const blueprint=engineering.BlueprintName;const grade=engineering.Level;if(typeof blueprint!=="string"||!Number.isInteger(grade)||grade<1||grade>5){return engineeringNormalizationUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const variant=identifyPreEngineeredVariant(module);const restoresBakedEffect=variant?.experimental!==void 0&&variant.experimental.trim().toLowerCase()===experimental?.trim().toLowerCase();if(experimental!==null&&!experimentalAvailableFor(module.Item,experimental)&&!restoresBakedEffect){return engineeringNormalizationUnsupported("unsupportedExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:experimental})}if(variant&&variant.acquisition!=="mercenary"){const stock=this.#engineeringBaseStats(module);if(!stock){return engineeringNormalizationUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const missing=missingBaseLabels(stock,baseStats(stock),[],effect?.modifiers);if(missing.length>0){return engineeringNormalizationUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}const{experimental:originalEffect,...withoutEffect}=variant;const adjusted=experimental===null?withoutEffect:{...withoutEffect,experimental:experimental};const resolved=getPreEngineeredStats(withoutEffect);if(!resolved){return engineeringNormalizationUnsupported("unknownModule",{slot:module.Slot,symbol:module.Item})}const replacement={BlueprintName:engineering.BlueprintName,Level:engineering.Level,Quality:1,...experimental===null?{}:{ExperimentalEffect:experimental},Modifiers:getPreEngineeredJournalModifiers(adjusted)};this.#replaceModule(module.Slot,{...module,Engineering:replacement},cloneModuleStats(resolved),getPreEngineeredModifiers(adjusted))}else{const proof=ordinaryEngineeringProof(module.Item,engineering,effect);if(proof==="unproven"||proof==="proven"&&!blueprintAvailableFor(module.Item,blueprint)){return engineeringNormalizationUnsupported("unidentifiedPreEngineeredVariant",{slot:module.Slot,symbol:module.Item,blueprint:blueprint})}const recipe=resolveBlueprintForModule(module.Item,blueprint);const blueprintGrade=getBlueprintGrade(recipe,grade);if(!blueprintGrade||!blueprintAvailableFor(module.Item,blueprint)){return engineeringNormalizationUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item,blueprint:blueprint,grade:grade})}const base=this.#engineeringBaseStats(module)??stats;const canonical=primitiveEngineeringInputsFor(base,blueprintGrade,effect);const missing=missingBaseLabels(base,baseStats(base),canonical.grade.features,canonical.experimental?.modifiers);if(missing.length>0){return engineeringNormalizationUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}this.applyBlueprint(module.Slot,blueprint,{grade:grade,quality:1,...experimental===null?{}:{experimental:experimental}})}return deepFreeze({kind:"normalized",previousQuality:previousQuality,quality:1})}setPreEngineeredVariant(slotKey,variant){if(variant===null||typeof variant!=="object"){throw new TypeError(`ShipLoadout.setPreEngineeredVariant: variant must be a pre-engineered variant, received ${describeValue(variant)}`)}requireString(variant.symbol,"ShipLoadout.setPreEngineeredVariant: variant.symbol");requireString(variant.blueprint,"ShipLoadout.setPreEngineeredVariant: variant.blueprint");requireString(variant.acquisition,"ShipLoadout.setPreEngineeredVariant: variant.acquisition");requireStringIfPresent(variant.experimental,"ShipLoadout.setPreEngineeredVariant: variant.experimental");const known=getPreEngineeredVariants(variant.symbol).find(candidate=>candidate.blueprint.toLowerCase()===variant.blueprint.toLowerCase()&&candidate.grade===variant.grade&&(candidate.experimental?.toLowerCase()??"")===(variant.experimental?.toLowerCase()??"")&&candidate.acquisition===variant.acquisition);if(!known){throw new RangeError(`ShipLoadout.setPreEngineeredVariant: no catalogued variant "${truncate(variant.blueprint)}" for module "${truncate(variant.symbol)}"`)}const stats=getPreEngineeredStats(known);const unresolved=unresolvedModifiers(known);if(unresolved.length>0){throw new TypeError(`ShipLoadout.setPreEngineeredVariant: cannot resolve "${truncate(variant.blueprint)}" for module "${truncate(variant.symbol)}"; missing base stats for ${unresolved.join(", ")}`)}this.setModule(slotKey,stats);const module=this.#fittedModuleFor(slotKey);const engineering={BlueprintName:known.blueprint,Level:known.grade,Quality:1,...known.experimental===void 0?{}:{ExperimentalEffect:known.experimental},...known.modifiers?.length?{Modifiers:getPreEngineeredJournalModifiers(known)}:{}};this.#replaceModule(module.Slot,{...module,Engineering:engineering},cloneModuleStats(stats),getPreEngineeredModifiers(known));return this}clearEngineering(slotKey){const module=this.#fittedModuleFor(slotKey);if(module&&this.#statsFor(module)?.engineeringLocked){throw new TypeError(`ShipLoadout.clearEngineering: module "${truncate(module.Item)}" is a final pre-engineered article and its engineering cannot be removed`)}if(module?.Engineering){const baseStats2=this.#engineeringBaseStats(module);const bare={Slot:module.Slot,Item:module.Item};if(module.On!==void 0)bare.On=module.On;if(module.Priority!==void 0){bare.Priority=module.Priority}if(module.Health!==void 0)bare.Health=module.Health;if(module.Value!==void 0)bare.Value=module.Value;this.#replaceModule(module.Slot,bare,baseStats2??void 0)}return this}setModuleEnabled(slotKey,on){this.#patchModule(slotKey,{On:on});return this}setModulePriority(slotKey,priority){if(!Number.isInteger(priority)||priority<0||priority>4){throw new RangeError(`ShipLoadout: power priority must be an integer 0-4, got ${truncate(priority)}`)}this.#patchModule(slotKey,{Priority:priority});return this}#patchModule(slotKey,patch){const module=this.#fittedModuleFor(slotKey);if(!module){throw new RangeError(`ShipLoadout: slot "${truncate(slotKey)}" is empty`)}this.#modules.set(module.Slot,cloneLoadoutModule({...module,...patch}));this.#slotCache.clear()}toLoadoutEvent(options={}){const unladenMass=this.#computedUnladenMass().value;const cargoCapacity=this.#computedCargoCapacity().value;const fuel=this.#computedFuelCapacity().value;const maxJumpRange=this.#exportableJumpRange(unladenMass);return exportLoadoutEvent({shipSymbol:this.#shipSymbol,...this.#top.ShipName===void 0?{}:{shipName:this.#top.ShipName},...this.#top.ShipIdent===void 0?{}:{shipIdent:this.#top.ShipIdent},modules:this.#modules,layout:this.#layout(),sourcePurchase:this.#sourcePurchase,retailHullValue:this.#ship.hullCost,unladenMass:unladenMass,cargoCapacity:cargoCapacity,fuelCapacity:fuel,maxJumpRange:maxJumpRange,statsFor:module=>this.#statsFor(module)},options)}toSlef(options){return toSlef(this.toLoadoutEvent(options),options.header)}toSlefString(options){return stringifySlef(this.toSlef(options),{indent:options.indent??0})}#exportableJumpRange(unladenMass){if(unladenMass===null)return null;let drive;try{drive=this.#resolveDrive()}catch{return null}if(drive===null)return null;const tank=this.#computedFuelCapacity().value;if(tank===null)return null;return singleJumpRange(unladenMass,Math.min(tank.main,drive.maxFuel),drive)}get frameShiftDrive(){const drive=this.#resolveDrive();if(drive===null)throw new TypeError("ShipLoadout: build has no frame shift drive");return drive}#maxJumpFuel(fsd){return Math.min(this.#requireFuelCapacity().main,fsd.maxFuel)}frameShiftDriveMassFactor(options={}){requireLoadOptions("ShipLoadout.frameShiftDriveMassFactor",options);const fuel=options.fuel??this.#requireFuelCapacity().main;return frameShiftDriveMassFactor(this.#requireMass(options.cargo??0),fuel,this.frameShiftDrive)}maxJumpRange(){const fsd=this.frameShiftDrive;return singleJumpRange(this.#requireMass(0),this.#maxJumpFuel(fsd),fsd)}jumpRange(options={}){requireLoadOptions("ShipLoadout.jumpRange",options);const fsd=this.frameShiftDrive;const fuel=options.fuel??this.#requireFuelCapacity().main;return singleJumpRange(this.#requireMass(options.cargo??0),fuel,fsd)}ladenJumpRange(){return this.jumpRange({cargo:this.#requireCargoCapacity()})}fuelPerJump(distance,options={}){requireLoadOptions("ShipLoadout.fuelPerJump",options);const fsd=this.frameShiftDrive;const fuel=options.fuel??this.#requireFuelCapacity().main;return fuelPerJump(distance,this.#requireMass(options.cargo??0),fuel,fsd)}totalRange(options={}){requireLoadOptions("ShipLoadout.totalRange",options);return totalRange(this.#requireMass(options.cargo??0),options.fuel??this.#requireFuelCapacity().main,this.frameShiftDrive)}standardLoadResult(load){if(load!=="maximum"&&load!=="unladen"&&load!=="laden"){throw new RangeError("ShipLoadout.standardLoadResult: load must be 'maximum', 'unladen', or 'laden'")}const fuel=this.fuelCapacityResult;const cargo=load==="laden"?this.cargoCapacityResult:completeResult(0);const mass=load==="maximum"?this.unladenMassResult:completeResult(0);const issues=[...fuel.issues,...cargo.issues,...mass.issues];let drive=null;let maximumFuel=null;if(load==="maximum"){const fitted=this.#frameShiftDriveModule();let driveError=null;try{drive=this.#resolveDrive();maximumFuel=drive?.maxFuel??null}catch(error){if(!(error instanceof Error))throw error;driveError=error}if(maximumFuel===null){issues.push({field:"frameShiftDrive",reason:fitted?"unresolved":"missing",slot:fitted?.Slot??"FrameShiftDrive",...fitted?{symbol:fitted.Item}:{},message:driveError?.message??"FrameShiftDrive: no frame shift drive is fitted",params:fitted?{field:"frameShiftDrive",reason:"unresolved",slot:fitted.Slot,symbol:fitted.Item}:{field:"frameShiftDrive",reason:"missing",slot:"FrameShiftDrive"}})}}if(issues.length>0){return incompleteResult(issues)}const value=Object.freeze({fuel:load==="maximum"?Math.min(fuel.value.main,maximumFuel):fuel.value.main,cargo:cargo.value});if(load==="maximum"){try{this.jumpRange(value)}catch(error){if(!(error instanceof RangeError))throw error;const fitted=this.#frameShiftDriveModule();const field=drive!==null&&(!Number.isFinite(drive.maxFuel)||drive.maxFuel<0)?"frameShiftDrive":!Number.isFinite(value.fuel)||value.fuel<0?"fuelCapacity":!Number.isFinite(mass.value)||mass.value<0?"mass":"frameShiftDrive";const driveParams=field==="frameShiftDrive"&&fitted?{slot:fitted.Slot,symbol:fitted.Item}:{};return incompleteResult([{field:field,reason:"invalid",...driveParams,message:error.message,params:{field:field,reason:"invalid",...driveParams}}])}}return completeResult(value)}jumpRangeSummary(){const maximum=this.#require(this.standardLoadResult("maximum"),"maximum load");const unladen=this.#require(this.standardLoadResult("unladen"),"unladen load");const laden=this.#require(this.standardLoadResult("laden"),"laden load");return{max:this.jumpRange(maximum),unladen:this.jumpRange(unladen),laden:this.jumpRange(laden),totalMax:this.totalRange(maximum),totalUnladen:this.totalRange(unladen),totalLaden:this.totalRange(laden)}}powerBudget(){const modules=[...this.#modules.values()];const consumers=[];for(const module of modules){const consumer=powerConsumerFor(module,this.#statsFor(module));if(consumer)consumers.push(consumer)}return powerBudget(powerAvailable(modules,module=>this.#statsFor(module)),consumers)}heatMetrics(){const input=heatInputFor(this.#ship,this.#modulesForEffectiveStats(),this.powerBudget(),module=>this.#statsFor(module));return input?heatMetrics(input):null}mobilityMetrics(options={}){requireEnginesPips("ShipLoadout.mobilityMetrics",options.enginesPips??4);requireLoadOptions("ShipLoadout.mobilityMetrics",options);return this.mobilityMetricsResult(options).value}mobilityMetricsResult(options={}){const enginesPips=requireEnginesPips("ShipLoadout.mobilityMetricsResult",options.enginesPips??4);requireLoadOptions("ShipLoadout.mobilityMetricsResult",options);const input=mobilityInputResultFor(this.#ship,[...this.#modules.values()],()=>this.powerBudget(),()=>{const main=options.fuel??this.#top.FuelCapacity?.Main??this.#requireFuelCapacity().main;return this.#requireMass(options.cargo??0)+main},enginesPips,module=>this.#statsFor(module));if(!input.complete)return input;return completeResult(mobilityMetrics(input.value))}shieldMetrics(options={}){requireSystemsPips("ShipLoadout.shieldMetrics",options.systemsPips??0);return this.shieldMetricsResult(options).value}shieldMetricsResult(options={}){const systemsPips=requireSystemsPips("ShipLoadout.shieldMetricsResult",options.systemsPips??0);const input=shieldInputResultFor(this.#ship,[...this.#modules.values()],()=>this.powerBudget(),systemsPips,module=>this.#statsFor(module));if(!input.complete)return input;return completeResult(shieldMetrics(input.value))}shieldRecovery(options={}){requireSystemsPips("ShipLoadout.shieldRecovery",options.systemsPips??4);return this.shieldRecoveryResult(options).value}shieldRecoveryResult(options={}){const systemsPips=requireSystemsPips("ShipLoadout.shieldRecoveryResult",options.systemsPips??4);const input=shieldRecoveryInputResultFor(this.#ship,[...this.#modules.values()],()=>this.powerBudget(),systemsPips,module=>this.#statsFor(module));if(!input.complete)return input;return completeResult(shieldRecovery(input.value))}cellBanks(){const modules=[...this.#modules.values()];const banks=orderBySlotLayout(cellBankInputsFor(modules,this.powerBudget(),module=>this.#statsFor(module)),this.#layout(),bank=>bank.slot);return cellBankSummary(banks)}retailCredits(){const hull=this.#ship.hullCost;let modules=0;const unpriced=[];for(const module of this.#modules.values()){const stats=this.#statsFor(module);if(stats?.cost!==void 0){modules+=stats.cost}else if(stats!==null||!isNonOutfittingSlot(module.Slot)&&!isBuiltInHullModule(module)){unpriced.push({slot:module.Slot,symbol:module.Item})}}return deepFreeze({hull:hull,modules:modules,rebuy:Math.trunc((hull+modules)*.05),unpriced:unpriced})}mercCoinCost(){let total=0;for(const slotKey of this.#modules.keys()){total+=this.fittedModuleAt(slotKey)?.preEngineeredVariant?.mercCoinCost??0}return total}armourMetrics(){return armourMetrics(armourInputFor(this.#ship,[...this.#modules.values()],module=>this.#statsFor(module)))}weaponMetrics(){const weapons=[];for(const module of this.#modules.values()){const record=this.#statsFor(module);const stats=weaponStatsFor(this.#moduleForEffectiveStats(module),record);if(!stats)continue;weapons.push({slot:module.Slot,symbol:module.Item,name:record?.name??module.Item,enabled:module.On!==false,metrics:weaponMetrics(stats),ammunition:ammunitionCapacity(stats),...stats.maximumRange===void 0?{}:{maximumRange:stats.maximumRange},...stats.falloffRange===void 0?{}:{falloffRange:stats.falloffRange},...stats.projectileRange===void 0?{}:{projectileRange:{...stats.projectileRange}},...stats.armourPiercing===void 0?{}:{armourPiercing:stats.armourPiercing}})}const orderedWeapons=orderBySlotLayout(weapons,this.#layout(),weapon=>weapon.slot);return{weapons:orderedWeapons,total:sumWeaponMetrics(orderedWeapons.filter(weapon=>weapon.enabled).map(weapon=>weapon.metrics))}}weaponsCapacitorMetrics(options={}){const weaponsPips=options.weaponsPips??4;if(!Number.isFinite(weaponsPips)||weaponsPips<0||weaponsPips>4){throw new RangeError("ShipLoadout.weaponsCapacitorMetrics: weaponsPips must be a finite number from 0 to 4")}return weaponsCapacitorMetrics(weaponsCapacitorInputFor(this.#modulesForEffectiveStats(),weaponsPips,this.powerBudget(),module=>this.#statsFor(module)))}distributorMetrics(options={}){const pips={systemsPips:options.systemsPips??4,enginesPips:options.enginesPips??4,weaponsPips:options.weaponsPips??4};for(const field of["systemsPips","enginesPips","weaponsPips"]){const value=pips[field];if(!Number.isFinite(value)||value<0||value>4){throw new RangeError(`ShipLoadout.distributorMetrics: ${field} must be a finite number from 0 to 4`)}}const input=distributorInputFor(this.#modulesForEffectiveStats(),pips,this.powerBudget(),module=>this.#statsFor(module));return input?distributorMetrics(input):null}#layout(){if(this.#layoutCache===void 0){this.#layoutCache=Object.freeze(enumerateSlots(this.#ship))}return this.#layoutCache}#requireSlot(slotKey){const wanted=requireString(slotKey,SLOT_KEY).toLowerCase();const slot=this.#layout().find(s=>s.key.toLowerCase()===wanted);if(!slot){throw new RangeError(`ShipLoadout: hull "${truncate(this.#shipSymbol)}" has no slot "${truncate(slotKey)}"`)}return slot}#fittedKey(slotKey){return matchingKeyIn(this.#modules,requireString(slotKey,SLOT_KEY))}#fittedModuleFor(slotKey){const key=this.#fittedKey(slotKey);return key===null?void 0:this.#modules.get(key)}#require(result,what){if(result.value===null){throw new TypeError(`ShipLoadout: cannot determine ${what} (${result.issues.map(i=>i.message).join("; ")})`)}return result.value}#requireMass(cargo){return this.#require(this.unladenMassResult,"mass")+cargo}#requireFuelCapacity(){return this.#require(this.fuelCapacityResult,"fuel capacity")}#requireCargoCapacity(){return this.#require(this.cargoCapacityResult,"cargo capacity")}#calculationModules(){return[...this.#modules.values()].map(module=>{const stats=this.#statsFor(module);const symbol=module.Item.toLowerCase();const parsedSlot=parseSlotName(module.Slot);const unresolvedOutfitting=stats===null&&!isNonOutfittingSlot(module.Slot)&&!isBuiltInHullModule(module);const isCargoRack=stats?.cargoCapacity!==void 0||symbol.includes("cargorack");const isFuelTank=stats?.fuelCapacity!==void 0||stats?.slot==="fuelTank"||symbol.startsWith(FUEL_TANK_PREFIX);const mayCarryCapacity=unresolvedOutfitting&&(parsedSlot===null||parsedSlot.kind==="optional");const mayCarryFuel=mayCarryCapacity||unresolvedOutfitting&&parsedSlot?.kind==="core"&&parsedSlot.core==="fuelTank";return{slot:module.Slot,symbol:module.Item,mass:this.#moduleMass(module),...isCargoRack||mayCarryCapacity?{cargoCapacity:isCargoRack?this.#moduleCapacity(module,"CargoCapacity","cargoCapacity"):null}:{},...isFuelTank||mayCarryFuel?{fuelCapacity:isFuelTank?this.#moduleCapacity(module,"FuelCapacity","fuelCapacity"):null}:{}}})}#moduleLimits(){const entries=[...this.#modules.values()].flatMap(module=>{const stats=this.#statsFor(module);return stats===null?[]:[stats]});return calculateModuleLimits(entries)}#moduleStatsAt(slotKey){const fitted=this.#fittedModuleFor(slotKey);return fitted===void 0?null:this.#statsFor(fitted)}#engineeringBaseStats(module){const fitted=this.#statsFor(module);if(!module.Engineering||identifyPreEngineeredVariant(module)===null)return fitted;const stock=builtInModuleBySymbol(module.Item,FITTED_ITEM);if(!stock)return fitted;return fitted?.engineeringLocked?cloneModuleStats({...stock,engineeringLocked:true}):stock}#moduleForEffectiveStats(module){const modifiers=this.#primitiveModifiers.get(module.Slot);if(modifiers===void 0||module.Engineering===void 0)return module;return{...module,Engineering:{...module.Engineering,Modifiers:modifiers}}}#modulesForEffectiveStats(){return[...this.#modules.values()].map(module=>this.#moduleForEffectiveStats(module))}#moduleLimitRegression(slotKey,replacement,current=this.#moduleLimits(),previous=this.#moduleStatsAt(slotKey)){if(previous?.limitGroup===void 0&&previous?.limitIncrease===void 0&&replacement?.limitGroup===void 0&&replacement?.limitIncrease===void 0){return null}for(const usage of current){const count=usage.count-Number(previous?.limitGroup===usage.group)+Number(replacement?.limitGroup===usage.group);const increase=usage.increase-(previous?.limitIncrease?.group===usage.group?previous.limitIncrease.amount:0)+(replacement?.limitIncrease?.group===usage.group?replacement.limitIncrease.amount:0);const limit=usage.baseLimit+increase;const excess=Math.max(0,count-limit);if(excess>usage.excess){return{...usage,increase:increase,limit:limit,count:count,excess:excess}}}return null}#replaceModule(slotKey,replacement,replacementStats,primitiveModifiers){const previous=this.#modules.get(slotKey)??null;this.#adjustImportedFigures(previous,replacement,replacementStats);if(replacement===null){this.#modules.delete(slotKey);this.#moduleStats.delete(slotKey);this.#primitiveModifiers.delete(slotKey)}else{this.#modules.set(slotKey,cloneLoadoutModule(replacement));if(replacementStats!==void 0)this.#moduleStats.set(slotKey,replacementStats);if(primitiveModifiers===void 0)this.#primitiveModifiers.delete(slotKey);else this.#primitiveModifiers.set(slotKey,primitiveModifiers)}this.#slotCache.clear()}#adjustImportedFigures(previous,next,nextStats){const previousMass=this.#moduleMass(previous);const nextMass=this.#moduleMass(next,nextStats);if(this.#top.UnladenMass!==void 0){if(previousMass===null||nextMass===null)delete this.#top.UnladenMass;else this.#top.UnladenMass+=nextMass-previousMass}const previousCargo=this.#moduleCapacity(previous,"CargoCapacity","cargoCapacity");const nextCargo=this.#moduleCapacity(next,"CargoCapacity","cargoCapacity",nextStats);if(this.#top.CargoCapacity!==void 0){if(previousCargo===null||nextCargo===null)delete this.#top.CargoCapacity;else this.#top.CargoCapacity+=nextCargo-previousCargo}const previousFuel=this.#moduleCapacity(previous,"FuelCapacity","fuelCapacity");const nextFuel=this.#moduleCapacity(next,"FuelCapacity","fuelCapacity",nextStats);if(this.#top.FuelCapacity?.Main!==void 0){const reserve=this.#top.FuelCapacity.Reserve;if(previousFuel===null||nextFuel===null){if(reserve===void 0)delete this.#top.FuelCapacity;else this.#top.FuelCapacity={Reserve:reserve}}else{this.#top.FuelCapacity={Main:this.#top.FuelCapacity.Main+nextFuel-previousFuel,...reserve===void 0?{}:{Reserve:reserve}}}}if(normalizeKey(previous?.Item,FITTED_ITEM)===normalizeKey(next?.Item,FITTED_ITEM)){return}if(previous!==null&&isCargoHatchSlot(previous.Slot)||next!==null&&isCargoHatchSlot(next.Slot)){return}delete this.#top.ModulesValue;delete this.#top.Rebuy}#moduleMass(module,statsOverride){if(module===null)return 0;if(isCargoHatchSlot(module.Slot))return 0;const modified=getLoadoutModifier(module,"Mass");if(modified!==null)return modified;const stats=statsOverride??this.#statsFor(module);if(stats?.mass!==void 0)return stats.mass;return stats===null&&isNonOutfittingSlot(module.Slot)?0:null}#moduleCapacity(module,modifierLabel,field,statsOverride){if(module===null)return 0;if(isCargoHatchSlot(module.Slot))return 0;const modified=getLoadoutModifier(module,modifierLabel);if(modified!==null)return modified;const stats=statsOverride??this.#statsFor(module);if(stats?.[field]!==void 0)return stats[field];const symbol=module.Item.toLowerCase();const isFuelTank=stats?.slot?stats.slot==="fuelTank":symbol.startsWith(FUEL_TANK_PREFIX);const shouldCarryCapacity=field==="cargoCapacity"?symbol.includes("cargorack"):isFuelTank;return shouldCarryCapacity?null:0}#frameShiftDriveModule(){for(const m of this.#modules.values()){const stats=this.#statsFor(m);const isDrive=stats?.slot?stats.slot==="frameShiftDrive":m.Item.toLowerCase().startsWith(FSD_PREFIX);if(isDrive){return m}}return void 0}#resolveDrive(){const fsdModule=this.#frameShiftDriveModule();if(!fsdModule)return null;const base=this.#statsFor(fsdModule);if(!base||base.fuelMul===void 0||base.fuelPower===void 0){throw new TypeError(`ShipLoadout: no jump constants in the stats catalogue for frame shift drive "${truncate(fsdModule.Item)}"`)}const optMass=getLoadoutModifier(fsdModule,"FSDOptimalMass")??base.optMass;const maxFuel=getLoadoutModifier(fsdModule,"MaxFuelPerJump")??base.maxFuel;if(optMass===void 0||maxFuel===void 0){const missing=[...optMass===void 0?["optMass"]:[],...maxFuel===void 0?["maxFuel"]:[]];throw new TypeError(`ShipLoadout: frame shift drive "${truncate(fsdModule.Item)}" has no ${missing.join(" or ")} in the stats catalogue`)}return{optMass:optMass,maxFuel:maxFuel,fuelMul:base.fuelMul,fuelPower:base.fuelPower,jumpBoost:this.#resolveJumpBoost()}}#resolveJumpBoost(){for(const m of this.#modules.values()){const stats=this.#statsFor(m);if(stats?.engineeringGroup!=="fsdBoosters"&&!m.Item.toLowerCase().startsWith(BOOSTER_PREFIX)){continue}if(m.On===false)continue;if(stats?.jumpBoost===void 0){throw new TypeError(`ShipLoadout: FSD booster "${truncate(m.Item)}" has no jumpBoost in the stats catalogue`)}return stats.jumpBoost}return 0}#statsFor(module){if(module===null)return null;const stats=this.#moduleStats.get(module.Slot)??builtInModuleBySymbol(module.Item,FITTED_ITEM);if(stats)return stats;return isBuiltInHullModule(module)?builtInModuleBySymbol("ModularCargoBayDoor","ShipLoadout: built-in module"):null}};export{LoadoutEditError,ShipLoadout};//# sourceMappingURL=chunk-WVKRSRLO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ships/internal/loadout-metrics.ts","../src/ships/internal/loadout-fitting.ts","../src/ships/internal/loadout-export.ts","../src/ships/internal/loadout-import.ts","../src/ships/ship-loadout.ts"],"names":["shieldMetrics","getShipBySymbol","getShipByName","parseSlef","toSlef","stringifySlef","getLoadoutModifier","sourcePurchaseFromLoadout","getSourceModuleValue","weaponsCapacitorMetrics","powerBudget","isCargoHatchSlot","matchingKeyIn","ownKeyIn","isBuiltInHullModule","isNonOutfittingSlot","cloneLoadoutModule","identifyPreEngineeredVariant","cloneModuleStats","availableBlueprintsFor","availableExperimentalsFor","blueprintAvailableFor","blueprintRoutesFor","experimentalAvailableFor","primitiveEngineeringInputsFor","missingBaseLabels","journalModifiersFor","getPreEngineeredStats","getPreEngineeredJournalModifiers","getPreEngineeredModifiers","ordinaryEngineeringProof","unresolvedModifiers","orderBySlotLayout","FITTED_ITEM","isFinalGuardianWeaponEngineering","scaleDamageComponents","weaponMetrics","sumWeaponMetrics","combinedRateOfFire","builtInModuleBySymbol","getBulkheadsForShip","getPreEngineeredVariants","shieldRecovery","cellBankSummary","completeResult","calculateUnladenMass","calculateCargoCapacity","calculateFuelCapacity","incompleteResult","validateLoadout","fixedSlotReason","mobilityMetrics","calculateModuleLimits","ALL_MODULES","CORE_MODULES","getExperimentalEffect","heatMetrics","singleJumpRange","frameShiftDriveMassFactor","fuelPerJump","totalRange","ammunitionCapacity","armourMetrics","baseStats","computeModifiers","labelsForDamageType","scaleForLabel","fieldForLabel","labelsForField","capabilityValueForLabel","damageTypeForLabel","resolveBlueprintForModule","getExperimentalsForModule","getBlueprintGrade","getDefaultLoadout","distributorMetrics","loadoutSlotName","parseSlotName","enumerateSlots","SLOT_RESTRICTION_LABELS","normalizeKey","truncate","describeValue","requireString","requireStringIfPresent","deepFreeze","PREFIX","powerPlant","thrusters","frameShiftDrive","powerDistributor","shieldGenerator","shieldCellBank","shieldBooster","shieldReinforcement","hullReinforcement","moduleReinforcement","startsWithAny","symbol","prefixes","some","prefix","toLowerCase","startsWith","isPowerDistributor","module","stats","slot","Item","isPowerPlant","parsed","Slot","kind","core","isThruster","isFrameShiftDrive","isEnabled","On","priorityOf","Priority","effectiveStat","field","stated","statedModifier","base","label","modified","effectiveCapability","Engineering","Modifiers","modifier","Label","effectiveDamageDistribution","fromEffect","ExperimentalEffect","damageDistribution","distribution","resolved","seen","Set","type","has","add","Value","convertsDamage","modifierRatio","effective","relatedStat","ratio","effectiveModule","merged","fields","Object","keys","key","capability","value","engineeringGroup","massRatio","minMass","maxMass","performanceRatio","minMultiplier","maxMultiplier","category","normalizeEffectiveWeapon","damageComponents","damage","powerConsumerFor","draw","parsedSlot","mounted","deployedOnly","alwaysPowered","common","priority","enabled","inherentlyPassiveSlot","drawUnknown","powerAvailable","modules","statsFor","metricIssue","reason","defaultSlot","params","message","unavailable","powerPlantIssueFor","capacity","Number","isFinite","powerDrawIssueFor","consumer","poweredMetricBudgetFor","getBudget","plantIssue","drawIssue","budget","available","poweredStates","retracted","poweredShieldGeneratorResultFor","powered","complete","mapResistanceFields","read","kineticResistance","thermalResistance","explosiveResistance","causticResistance","resistancesOf","shieldInputFor","ship","systemsPips","generator","boosters","reinforcement","strengthRatio","optMass","Math","max","optMultiplier","push","shieldBoost","hullMass","baseShieldStrength","shieldInputResultFor","fitted","input","mobilityInputResultFor","mass","enginesPips","optSpeedMultiplier","speedCurve","minSpeedMultiplier","maxSpeedMultiplier","optRotationMultiplier","rotationCurve","minRotationMultiplier","maxRotationMultiplier","minimumSpeed","maximumSpeed","boost","minPitch","pitch","minRoll","roll","minYaw","yaw","shieldRecoveryInputResultFor","generatorModule","distributor","generatorStats","distributorStats","strength","regenRate","brokenRegenRate","distributorDraw","systemsCapacity","systemsRecharge","weaponsCapacitorInputFor","weaponsPips","weaponsCapacity","weaponsRecharge","sustainedEnergyPerSecond","deployed","weapon","weaponStatsFor","distributorInputFor","pips","enginesCapacity","enginesRecharge","heatInputFor","heatEfficiency","thrusterHeatRate","deployedThrusterHeatRate","fsdHeatRate","weapons","running","heat","heatPerSecond","sustainedHeatPerSecond","heatCapacity","heatDissipation","retractedPowerDraw","poweredDraw","deployedPowerDraw","unknownDraws","map","state","bands","reduce","total","band","min","length","poweredRetracted","poweredDeployed","cellBankInputsFor","banks","ammunition","reinforcementRate","shieldBankReinforcement","cells","spinUp","shieldBankSpinUp","duration","shieldBankDuration","shieldBankHeat","stockBulkhead","variants","name","find","v","endsWith","armourInputFor","reinforcements","moduleReinforcements","bulkhead","hullBoost","moduleProtection","integrity","stock","baseArmour","WEAPON_FIELDS","projectileRange","burstAdjustedRateOfFire","touched","rate","rateOfFire","statedDamagePerSecond","firingFactor","roundsPerShot","maximumRange","falloffRange","MILITARY_PREFIXES","MINING_PREFIXES","CARGO_PREFIXES","RESTRICTED_SLOT_PREFIXES","mining","military","cargo","limpetController","vesselHangar","passenger","planetaryApproachSuite","problem","constraint","restrictionProblem","restriction","moduleSlotProblem","required","restrictedToSlot","moduleFitProblem","shipSymbol","hull","armourHull","armourShipName","armourShipSymbol","shipName","restricted","restrictedToShips","allowedShipNames","labels","index","join","allowedShipSymbols","wrongMount","moduleSlot","requiredCore","isFuelTank","class","size","moduleClass","slotSize","moduleFitError","REBUY_FRACTION","exportLoadoutEvent","options","fromSource","credits","source","sourcePurchase","totals","sourceTotalsHold","hullValue","retailHullValue","modulesValue","computedModulesValue","rebuy","trunc","event","Ship","ShipName","shipIdent","ShipIdent","HullValue","ModulesValue","unladenMass","UnladenMass","cargoCapacity","CargoCapacity","maxJumpRange","MaxJumpRange","fuelCapacity","FuelCapacity","Main","main","Reserve","reserve","Rebuy","Modules","exportModules","ordered","moduleOrder","slotOrderedModules","layout","values","on","explicitPower","sourceModuleValue","moduleValue","Health","sum","cost","SOURCE_ITEM","entry","item","moduleValues","get","captureLoadoutEvent","Array","isArray","captureEach","captureModule","capture","captured","health","engineering","captureEngineering","experimental","experimentalLocalised","ExperimentalEffect_Localised","modifiers","BlueprintName","Level","Quality","normalizeLoadoutEvent","rawEvent","TypeError","Map","slots","entries","normalizedSlot","set","top","moduleStats","primitiveModifiers","variant","catalogueVariantStats","variantStats","retainsBakedExperimental","trim","engineeringLocked","originalExperimental","withoutExperimental","currentExperimental","currentVariant","guardianFinal","normalizedBlueprint","normalizedExperimental","exact","candidate","blueprint","grade","guardianBase","SLOT_KEY","requireLoadOptions","scope","RangeError","requireEnginesPips","requireSystemsPips","LoadoutEditError","code","constructor","super","this","structuredClone","experimentalEffectUnsupported","engineeringNormalizationUnsupported","FSD_PREFIX","BOOSTER_PREFIX","FUEL_TANK_PREFIX","ShipLoadout","_ShipLoadout","slotCache","layoutCache","fromSlef","imported","data","fromImported","fromLoadout","defaultHatch","capturedHatchKey","capturedHatch","ownSlot","build","repairFixedMount","empty","requested","hatch","loadout","unladenMassResult","computedUnladenMass","calculationModules","fuelCapacityResult","cap","freeze","computed","computedFuelCapacity","cargoCapacityResult","computedCargoCapacity","reserveFuelCapacity","validation","byKey","builtIn","fitProblem","known","requiresKnownSlot","fitError","fitConstraint","fitParams","exclusionGroup","limitGroup","limitIncrease","cached","filter","currentLimits","moduleLimits","moduleStatsAt","fixedReason","immovableReason","moduleLimitRegression","fittedModuleAt","removable","slotKey","fittedModuleFor","raw","moduleForEffectiveStats","effectiveStats","preEngineeredVariant","fittedModules","flatMap","availableBlueprints","availableExperimentalEffects","modulesForSlot","requireSlot","occupied","group","currentStats","wanted","fittedKey","resultSlot","canonicalKey","status","current","valid","defaultModule","ownKey","replacement","replacementStats","replaceModule","setModule","conflict","previousSlot","previousSymbol","limitProblem","count","limit","removeModule","applyBlueprint","fdname","wantedGrade","wantedQuality","quality","wantedExperimental","fittedStats","recipe","named","written","acquisition","isInteger","offered","route","engineeringBaseStats","canonical","missing","features","damageModifier","OriginalValue","setExperimentalEffect","previous","effect","restoresBakedEffect","originalEffect","withoutEffect","adjusted","currentEffect","blueprintGrade","previousExperimental","completeEngineeringGrade","previousQuality","proof","setPreEngineeredVariant","unresolved","clearEngineering","bare","setModuleEnabled","patchModule","setModulePriority","patch","clear","toLoadoutEvent","fuel","exportableJumpRange","hullCost","header","toSlefString","indent","drive","resolveDrive","tank","maxFuel","maxJumpFuel","fsd","requireFuelCapacity","requireMass","jumpRange","ladenJumpRange","requireCargoCapacity","distance","standardLoadResult","load","issues","maximumFuel","frameShiftDriveModule","driveError","error","Error","driveParams","jumpRangeSummary","maximum","require","unladen","laden","totalMax","totalUnladen","totalLaden","consumers","modulesForEffectiveStats","mobilityMetricsResult","shieldMetricsResult","shieldRecoveryResult","cellBanks","bank","retailCredits","unpriced","mercCoinCost","record","metrics","armourPiercing","orderedWeapons","s","result","what","i","unresolvedOutfitting","isCargoRack","includes","mayCarryCapacity","mayCarryFuel","moduleMass","moduleCapacity","usage","increase","amount","baseLimit","excess","adjustImportedFigures","delete","next","nextStats","previousMass","nextMass","previousCargo","nextCargo","previousFuel","nextFuel","statsOverride","modifierLabel","shouldCarryCapacity","m","isDrive","fsdModule","fuelMul","fuelPower","jumpBoost","resolveJumpBoost"],"mappings":"O,wmFAwEA,IAAMsF,OAAS,CACXC,WAAY,CAAC,iBAAkB,0BAC/BC,UAAW,CAAC,aAAc,6BAC1BC,gBAAiB,CAAC,kBAClBC,iBAAkB,CAAC,uBAAwB,gCAC3CC,gBAAiB,CAAC,uBAClBC,eAAgB,CAAC,sBACjBC,cAAe,CAAC,qBAChBC,oBAAqB,CAAC,mCACtBC,kBAAmB,CACf,wBACA,gCACA,kCAEJC,oBAAqB,CAAC,0BAA2B,oCAGrD,IAAMC,cAAgB,CAACC,OAAgBC,WACnCA,SAASC,KAAMC,QAAWH,OAAOI,cAAcC,WAAWF,SAG9D,SAASG,mBAAmBC,OAAuBC,OAC/C,OAAOA,OAAOC,KACRD,MAAMC,OAAS,mBACfV,cAAcQ,OAAOG,KAAMtB,OAAOI,iBAC5C,CAGA,SAASmB,aAAaJ,OAAuBC,OACzC,MAAMI,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