interface VoidPulsePreviewOrder {
	source: 'order' | 'example';
	label: string;
	identities: Record<
		'first_name' | 'first_initial' | 'anonymous' | 'someone' | 'customer',
		string
	>;
	locations: Record<
		'city' | 'region' | 'country' | 'city_country' | 'hidden',
		string
	>;
	product: string;
	product_image: string;
	time_ago: string;
}

interface VoidPulseCustomFont {
	id: string;
	family: string;
	url: string;
	format: string;
	attachment_id: number;
}

interface VoidPulseAdminConfig {
	nonce: string;
	root: string;
	woocommerce: boolean;
	canPublish: boolean;
	canExportAnalytics: boolean;
	canManageSettings: boolean;
	canManageIntegrations: boolean;
	canManageRoles: boolean;
	hasPaidPlans: boolean;
	isPremium: boolean;
	upgradeUrl: string;
	iconUrl: string;
	preview: VoidPulsePreviewOrder;
	pro?: boolean;
	customFonts?: VoidPulseCustomFont[];
}

interface VoidPulseFrontendConfig {
	rest: string;
	conversionTracking?: {
		rest: string;
		campaign_id: number;
		token: string;
	};
	template: string;
	delivery: import('./delivery').DeliverySettings;
	display?: {
		hide_mobile?: boolean;
		hide_desktop?: boolean;
	};
	timing: {
		initial_delay: number;
		duration: number;
		gap: number;
		maximum: number;
		loop: boolean;
		pause_hidden: boolean;
		animation: string;
		animation_duration: number;
		animation_easing: string;
	};
	style: {
		background: string;
		text: string;
		muted_text: string;
		accent: string;
		border: string;
		label_color?: string;
		headline_color?: string;
		message_color?: string;
		label_size?: number;
		headline_size?: number;
		message_size?: number;
		label_font?: string;
		headline_font?: string;
		message_font?: string;
		label_weight?: number;
		headline_weight?: number;
		message_weight?: number;
		radius: number;
		width: number;
		font_size: number;
		desktop_position: string;
		mobile_position: string;
		image_shape: string;
		show_image: boolean;
		show_close: boolean;
		show_label?: boolean;
		show_headline?: boolean;
	};
	labels: {
		activity: string;
		close: string;
		headline?: string;
	};
}

declare module '*.css';

interface VoidPulseProConfig {
	rest: string;
	productId: number;
	token: string;
	analytics: boolean;
	delivery: import('./delivery').DeliverySettings;
	customFonts?: VoidPulseCustomFont[];
	notifications: Array< {
		id: number;
		variant_id: number;
		type:
			| 'recent_sale'
			| 'review'
			| 'sales_summary'
			| 'viewer_count'
			| 'low_stock'
			| 'countdown'
			| 'announcement'
			| 'custom_activity';
		headline: string;
		message: string;
		label?: string;
		rating?: number;
		show_rating?: boolean;
		cta_label: string;
		cta_url: string;
		product_url?: string;
		image: string;
		template: string;
		style: {
			background: string;
			text: string;
			muted_text: string;
			accent: string;
			border: string;
			label_color?: string;
			headline_color?: string;
			message_color?: string;
			label_size?: number;
			headline_size?: number;
			message_size?: number;
			label_font?: string;
			headline_font?: string;
			message_font?: string;
			label_weight?: number;
			headline_weight?: number;
			message_weight?: number;
			position: 'bottom-left' | 'bottom-right';
			desktop_position: 'bottom-left' | 'bottom-right';
			mobile_position: 'bottom-left' | 'bottom-right';
			radius: number;
			font_size: number;
			width: number;
			image_shape: 'rounded' | 'square' | 'circle';
			show_image: boolean;
			show_close: boolean;
			show_label?: boolean;
			show_headline?: boolean;
		};
		timing: {
			initial_delay: number;
			duration: number;
			gap: number;
			maximum: number;
			loop: boolean;
			pause_hidden: boolean;
			order: string;
			animation: string;
			animation_duration: number;
			animation_easing: string;
		};
		display?: {
			hide_mobile?: boolean;
			hide_desktop?: boolean;
		};
		analytics_token: string;
	} >;
}

interface Window {
	jQuery?: {
		( target: Document ): {
			on(
				event: string,
				handler: (
					event: Event,
					fragments?: unknown,
					cartHash?: unknown,
					button?: { data?: ( key: string ) => unknown }
				) => void
			): void;
		};
	};
}

interface Window {
	wpFomoUnused?: never;
	voidPulseAdmin?: VoidPulseAdminConfig;
	voidPulse?: VoidPulseFrontendConfig;
	voidPulsePro?: VoidPulseProConfig;
	wp?: {
		media?: ( options: {
			title?: string;
			button?: { text?: string };
			multiple?: boolean;
			library?: { type?: string | string[] };
		} ) => {
			on: ( event: string, callback: () => void ) => void;
			open: () => void;
			state: () => {
				get: ( key: string ) => {
					first: () => {
						get: ( key: string ) => unknown;
						toJSON: () => { id?: number; filename?: string };
					};
				};
			};
		};
	};
	msCrypto?: Crypto;
	requestIdleCallback?: (
		callback: () => void,
		options?: { timeout: number }
	) => number;
}

interface Navigator {
	connection?: {
		saveData?: boolean;
	};
}
