package content

import (
	_ "embed"
	"fmt"
)

// Embedded library assets
//
//go:embed assets/insertr.min.js
var libraryMinJS string

//go:embed assets/insertr.js
var libraryJS string

// GetLibraryScript returns the appropriate library version
func GetLibraryScript(minified bool) string {
	if minified {
		return libraryMinJS
	}
	return libraryJS
}

// GetLibraryVersion returns the current embedded library version
func GetLibraryVersion() string {
	return "1.0.0"
}

// GetLibraryURL returns the appropriate library URL for script injection
func GetLibraryURL(minified bool, isDevelopment bool) string {
	if isDevelopment {
		// Local development URLs - relative to served content
		if minified {
			return "/insertr/insertr.min.js"
		}
		return "/insertr/insertr.js"
	}

	// Production URLs - use CDN
	return GetLibraryCDNURL(minified)
}

// GetLibraryCDNURL returns the CDN URL for production use
func GetLibraryCDNURL(minified bool) string {
	version := GetLibraryVersion()
	if minified {
		return fmt.Sprintf("https://cdn.jsdelivr.net/npm/@insertr/lib@%s/dist/insertr.min.js", version)
	}
	return fmt.Sprintf("https://cdn.jsdelivr.net/npm/@insertr/lib@%s/dist/insertr.js", version)
}
