package shape

import (
	

	
	
	
)

type shapePackage struct {
	*baseShape
}

const (
	packageTopMinHeight     = 34.
	packageTopMaxHeight     = 55.
	packageTopMinWidth      = 50.
	packageTopMaxWidth      = 150.
	packageHorizontalScalar = 0.5
	packageVerticalScalar   = 0.2
)

func ( *geo.Box) Shape {
	 := shapePackage{
		baseShape: &baseShape{
			Type: PACKAGE_TYPE,
			Box:  ,
		},
	}
	.FullShape = go2.Pointer(Shape())
	return 
}

func ( shapePackage) () *geo.Box {
	 := .Box.TopLeft.Copy()
	 := .Box.Height

	,  := getTopDimensions(.Box)
	.Y += 
	 -= 
	return geo.NewBox(, .Box.Width, )
}

func getTopDimensions( *geo.Box) (,  float64) {
	 = .Width * packageHorizontalScalar
	if .Width >= 2*packageTopMinWidth {
		 = math.Min(packageTopMaxWidth, math.Max(packageTopMinWidth, ))
	}
	 = math.Min(packageTopMaxHeight, .Height*packageVerticalScalar)
	return , 
}

func packagePath( *geo.Box) *svg.SvgPathContext {
	,  := getTopDimensions()

	 := svg.NewSVGPathContext(.TopLeft, 1, 1)
	.StartAt(.Absolute(0, 0))
	.L(false, , 0)
	.L(false, , )
	.L(false, .Width, )
	.L(false, .Width, .Height)
	.L(false, 0, .Height)
	.Z()
	return 
}

func ( shapePackage) () []geo.Intersectable {
	return packagePath(.Box).Path
}

func ( shapePackage) () []string {
	return []string{
		packagePath(.Box).PathData(),
	}
}

func ( shapePackage) (, , ,  float64) (float64, float64) {
	 :=  + 
	// We want to compute what the topHeight will be to add to inner height;
	// topHeight=(verticalScalar * totalHeight) and totalHeight=(topHeight + innerHeight)
	// so solving for topHeight we get: topHeight=innerHeight * (verticalScalar/(1-verticalScalar))
	 :=  * packageVerticalScalar / (1. - packageVerticalScalar)
	 :=  + math.Min(, packageTopMaxHeight)

	return math.Ceil( + ), math.Ceil()
}

func ( shapePackage) () (,  float64) {
	return defaultPadding, .8 * defaultPadding
}