/**
 * @todo outsource
 */
declare var __dirname;


namespace _heimdall
{
	
	/**
	 */
	export enum enum_condition {
		unknown = 0,
		ok = 1,
		concerning = 2,
		critical = 3,
	};
	
	
	/**
	 */
	export type type_result = {
		condition : enum_condition;
		info : any;
	};
	
	
	/**
	 */
	export type type_interval = (
		null
		|
		int
		/*
		|
		(
			"minute"
			|
			"hour"
			|
			"day"
			|
			"week"
		)
		 */
	);
	
	
	/**
	 */
	export type type_schedule = {
		regular_interval : type_interval;
		attentive_interval : type_interval;
		reminding_interval : type_interval;
	};
	
	
	/**
	 */
	export type type_notification = {
		kind : string;
		parameters : any;
	};
	
	
	/**
	 */
	export type type_check_common = {
		active ?: boolean;
		threshold ?: int;
		annoy ?: boolean;
		schedule ?: type_schedule;
		notifications ?: Array<type_notification>;
	};
	
	
	/**
	 */
	export type type_check = (
		type_check_common
		&
		{
			name : string;
			title : string;
			kind : string;
			parameters : any;
			custom : any;
		}
	);
	
	
	/**
	 */
	export type type_order = {
		defaults : type_check_common;
		includes : Array<string>;
		checks : Array<type_check>;
	};
	
	
	/**
	 */
	export type type_item_state = {
		timestamp : int;
		condition : _heimdall.enum_condition,
		count : (null | int);
		last_notification_timestamp : (null | int);
	};
	
	
	/**
	 */
	export function get_current_timestamp(
	) : int
	{
		return Math.floor(Date.now() / 1000);
	}
	
	
	/**
	 * converts a condition to a human readable string
	 */
	export function condition_show(
		condition : enum_condition
	) : string
	{
		return lib_plankton.translate.get(
			(
				(condition) => {
					switch (condition) {
						case enum_condition.unknown: return "conditions.unknown";
						case enum_condition.ok: return "conditions.ok";
						case enum_condition.concerning: return "conditions.concerning";
						case enum_condition.critical: return "conditions.critical";
					}
				}
			) (condition)
		)
	}
	
	/*
	def condition_encode(condition):
		return {
			enum_condition.unknown: "unknown",
			enum_condition.ok: "ok",
			enum_condition.concerning: "concerning",
			enum_condition.critical: "critical",
		}[condition]
		

	def condition_decode(condition_encoded):
		return {
			"unknown": enum_condition.unknown,
			"ok": enum_condition.ok,
			"warning": enum_condition.concerning, # deprecated
			"concerning": enum_condition.concerning,
			"critical": enum_condition.critical,
		}[condition_encoded]
	*/	
}
