package app

import (
	"embed"
	"fmt"
	"io/fs"
)

var (
	//go:embed static/*
	staticFiles embed.FS

	faviconICO = mustReadStaticFile("favicon.ico")
	homeImage  = mustReadStaticFile("avelonmemorycrystal.jpg")
	iconImage  = tryReadStaticFile("icon.png")
)

func mustReadStaticFile(name string) []byte {
	data, err := fs.ReadFile(staticFiles, "static/"+name)
	if err != nil {
		panic(fmt.Sprintf("failed to read embedded static file %q: %v", name, err))
	}

	return data
}

func tryReadStaticFile(name string) []byte {
	data, err := fs.ReadFile(staticFiles, "static/"+name)
	if err != nil {
		return nil
	}
	return data
}
