(function() {
	"use strict";
	
	function Icon(options) {
		if( typeof(options) === 'string' ) options = {icon:options};
		this.$super(options);
	}
	
	Icon.prototype = {
		build: function() {
			var o = this.options;
			var c = this.dom().innerText;
			if( o.icon || c ) this.icon(o.icon || c);
			this.empty();
		},
		icon: function(icon) {
			var classes = this.classes();
			var iconcls = [];
			for(var i=0; i < classes.length;i++) {
				var cls = classes[i];
				if( cls && cls.startsWith('icon-') ) iconcls.push(cls);
			}
			
			if( !arguments.length ) return iconcls[iconcls.length - 1];
			
			this.rc(iconcls);
			this.ac('icon-' + icon.split('.').join('-'));
			return this;
		}
	};
	
	// icon loader
	var packages = {};
	Icon.package = function(id, src, mapper) {
	};
	
	Icon.packages = function() {
		var args = [];
		for(var k in packages) args.push(k);
		return args;		
	};
	
	Icon.fname = 'Icon';	
	UI.component('icon', Icon);
})();
