//#region src/preview/rendering/ScaleConfig.ts
/**
* Immutable scaling configuration for a serialization operation.
*
* All scaling decisions are computed once at construction and cached.
* This ensures consistency across all stages of serialization.
*/
var ScaleConfig = class ScaleConfig {
	constructor(width, height, exportScale) {
		this.qualityMultiplier = 1.5;
		this.inputWidth = width;
		this.inputHeight = height;
		this.exportScale = exportScale;
		this.outputWidth = Math.floor(width * exportScale);
		this.outputHeight = Math.floor(height * exportScale);
		this.needsDOMScaling = exportScale < 1;
		Object.freeze(this);
	}
	/**
	* Compute optimal encoding scale for a canvas element.
	*
	* This is Stage 3 of the scaling architecture. Canvas pixels are scaled
	* independently from DOM content because they have intrinsic resolution.
	*
	* Algorithm:
	* 1. Calculate display scale (CSS size vs natural size)
	* 2. Multiply by export scale
	* 3. Multiply by quality multiplier (1.5x for sharpness)
	* 4. Cap at 1.0 (never upscale beyond natural resolution)
	*
	* @param params - Canvas dimensions (natural and display)
	* @returns Optimal scale for encoding (0.0 to 1.0)
	*/
	computeCanvasScale(params) {
		const { naturalWidth, naturalHeight, displayWidth, displayHeight } = params;
		const displayScaleX = displayWidth / naturalWidth;
		const displayScaleY = displayHeight / naturalHeight;
		const displayScale = Math.min(displayScaleX, displayScaleY);
		return Math.min(1, displayScale * this.exportScale * this.qualityMultiplier);
	}
	/**
	* Get the CSS transform value for DOM scaling.
	* Returns null if no scaling is needed.
	*/
	getDOMTransform() {
		return this.needsDOMScaling ? `scale(${this.exportScale})` : null;
	}
	/**
	* Get the wrapper dimensions for the CSS transform.
	* When DOM is scaled, the wrapper must be larger to accommodate
	* the scaled-down content.
	*/
	getDOMWrapperDimensions() {
		if (!this.needsDOMScaling) return {
			width: this.outputWidth,
			height: this.outputHeight
		};
		return {
			width: Math.floor(this.outputWidth / this.exportScale),
			height: Math.floor(this.outputHeight / this.exportScale)
		};
	}
	/**
	* Create a ScaleConfig from legacy options.
	* Maintains backward compatibility with existing callsites.
	*/
	static fromOptions(width, height, canvasScale) {
		return new ScaleConfig(width, height, canvasScale);
	}
};

//#endregion
export { ScaleConfig };
//# sourceMappingURL=ScaleConfig.js.map