package quality

import (
	
	
	

	
)

// Score preserves the original TALA penalty and separate area tie-breaker.
// Diagnostic geometry from Inspect is deliberately absent from this ordering.
type Score struct{ Penalty, Area float64 }

// Evaluate adapts the original evaluator for bounded refinement callers.
func ( context.Context,  *layoutgraph.Graph) (Score, error) {
	, ,  := EvaluateWithArea(, )
	return Score{Penalty: , Area: }, 
}

// Compare orders penalties exactly, then areas, with the same handling of
// non-finite values as the original seed-result comparator.
func ( Score) ( Score) int {
	if  := compareNumber(.Penalty, .Penalty, false);  != 0 {
		return 
	}
	return compareNumber(.Area, .Area, true)
}

func compareNumber(,  float64,  bool) int {
	 := finite() && (! ||  >= 0)
	 := finite() && (! ||  >= 0)
	if  && ! {
		return -1
	}
	if ! &&  {
		return 1
	}
	if ! {
		return 0
	}
	return cmp.Compare(, )
}

func finite( float64) bool { return !math.IsNaN() && !math.IsInf(, 0) }