import type { BeltId, BeltStackSize } from "./belts.ts";
import type {
  CalculatorInput,
  CalculationResult,
  Locale,
  LogisticsResult,
  LogisticsSettings,
  ProductionChainResult,
  QualityId,
} from "./types.ts";

export interface BlueprintBlockSettings {
  nodeKey?: string;
  beltId: BeltId;
  beltStackSize: BeltStackSize;
  autoUpgradeBelt: boolean;
  substationPriority: boolean;
  substationQuality: QualityId;
  roboportCoverage: boolean;
  roboportSide: "north" | "south";
  orientation: "horizontal" | "vertical";
  horizontalAlignment: "left" | "center" | "right";
  verticalAlignment: "top" | "center" | "bottom";
  snapToGrid: boolean;
  includeChain: boolean;
}

export const DEFAULT_BLUEPRINT_BLOCK_SETTINGS: BlueprintBlockSettings = {
  beltId: "transport-belt",
  beltStackSize: 1,
  autoUpgradeBelt: true,
  substationPriority: false,
  substationQuality: "normal",
  roboportCoverage: false,
  roboportSide: "north",
  orientation: "horizontal",
  horizontalAlignment: "center",
  verticalAlignment: "center",
  snapToGrid: true,
  includeChain: false,
};

/** The generator can only see this product and its own enabled chain. */
export interface BlueprintChainSource {
  input: CalculatorInput;
  result: CalculationResult;
  logistics: LogisticsResult;
  logisticsSettings: LogisticsSettings;
  chain?: ProductionChainResult;
}

export interface ProductionGeometryProps extends BlueprintChainSource {
  settings: BlueprintBlockSettings;
  onChange: (settings: BlueprintBlockSettings) => void;
  locale: Locale;
}
