// * ---------------------------------------------------------------------------    
// 
//       __ __  __
//     /  /   /   /     __/__/__
//     \ /   /   /  __   /  /  __  (/__
//      /   /   / /  /  /  /  /__) /  /
//     /   /   / (__/__/_ /__/____/  /_/
//             \
//               SOLUTIONS
// 
// 
//	=Global Functions - Components
//
// 	Setup and retrieve the project object configuration
//
// ---------------------------------------------------------------------------- *





// ------------------------------------------------
//	Add a component to the global component array
// ------------------------------------------------

@mixin mk-add-component( $name, $key, $value ) {

	$mk-global-components: mk-add-data( __mk_get_global_components_map(), $name, $key, $value ) !global;

}






// ------------------------------------------------
//	Retrieve a component from an array
// ------------------------------------------------

@function mk-component( $name, $key: 'base' ) {

	@if ( __mk_get_global_component_map() ) {

		$map: __mk_get_global_grid_config_map();
		$map-name-exists: map-has-key( $map, $name );
		$map-key-exists: null;

		// Check to see if the requested name exists
		@if ( $map-name-exists ) {

			$map-key-exists: map-has-key( map-get( $map, $name ), $key );

		}

		@else {

			@warn "Unknown '#{ $key }' in $mk-global-components( #{ $name } ).";
			@return null;

		}

		// Check to see if the requested key exists
		@if ( $map-key-exists ) {

			@return map-get( map-get( $map, $name ), $key );

		}

		@else {

			@warn "Unknown '#{ $name }' in $mk-global-objects.";
			@return null;

		}

	} 

	@else {

		@warn "Global grid has not yet been set.";
		@return null;

	}

}




// ------------------------------------------------
//	Get the global grid config map
// ------------------------------------------------

@function __mk_get_global_components_map() {

	@return $mk-global-components;

}