import { env } from '$env/dynamic/public';

export interface MutexLayerSet<ValidOpts> {
	map1: ValidOpts;
	map2: ValidOpts;
	map3: ValidOpts;
	map4: ValidOpts;
}
export interface OverlayLayerSet<ValidOpts> {
	map1: ValidOpts[];
	map2: ValidOpts[];
	map3: ValidOpts[];
	map4: ValidOpts[];
}

export type BaseLayers = 'osm';
export type DataLayers = 'noaa_mrms_merged_composite_reflectivity_qc';

export function tilerLayerUrl(id: DataLayers): string {
	if (!env.PUBLIC_TILER_URL_BASE) {
		throw new Error('PUBLIC_TILER_URL_BASE env var not set!');
	}
	const base = new URL(env.PUBLIC_TILER_URL_BASE);
	return (base + `${id}/{z}/{x}/{y}.png`).toString();
}
export function tilerLayerAttribution(id: DataLayers): string {
	let base;
	if (id === 'noaa_mrms_merged_composite_reflectivity_qc') {
		base = '&copy; NOAA';
	}
	return base + ', &copy; wxbox';
}
