;(function() {    function emoji(){}  	// settings  	emoji.img_path = 'emoji/';  	emoji.sheet_path = 'sheet_64.png';    	emoji.use_css_imgs = true;  	emoji.colons_mode = true;  	emoji.text_mode = true;  	emoji.include_title = true;  	emoji.allow_native = true;  	emoji.use_sheet = true;    	emoji.inits = {};  	emoji.map = {};    	emoji.replace_emoticons = function(str){  		emoji.init_emoticons();  		return str.replace(emoji.rx_emoticons, function(m, $1, $2){  			var val = emoji.map.emoticons[$2];  			return val ? $1+emoji.replacement(val, $2) : m;  		});  	};  	emoji.replace_emoticons_with_colons = function(str){  		emoji.init_emoticons();  		return str.replace(emoji.rx_emoticons, function(m, $1, $2){  			var val = emoji.data[emoji.map.emoticons[$2]][3][0];  			return val ? $1+':'+val+':' : m;  		});  	};  	emoji.replace_colons = function(str){  		emoji.init_colons();  		return str.replace(emoji.rx_colons, function(m){  			var idx = m.substr(1, m.length-2);  			var val = emoji.map.colons[idx];  			return val ? emoji.replacement(val, idx, ':') : m;  		});  	};  	emoji.replace_unified = function(str){  		emoji.init_unified();  		return str.replace(emoji.rx_unified, function(m){  			var val = emoji.map.unified[m];  			return val ? emoji.replacement(val) : m;  		});  	};    	emoji.replacement = function(idx, actual, wrapper){  		wrapper = wrapper || '';  		if (emoji.colons_mode) return ':'+emoji.data[idx][3][0]+':';  		var text_name = (actual) ? wrapper+actual+wrapper : emoji.data[idx][6] || wrapper+emoji.data[idx][3][0]+wrapper;  		if (emoji.text_mode) return text_name;  		emoji.init_env();  		if (emoji.replace_mode == 'unified'  && emoji.allow_native && emoji.data[idx][0][0]) return emoji.data[idx][0][0];  		if (emoji.replace_mode == 'softbank' && emoji.allow_native && emoji.data[idx][1]) return emoji.data[idx][1];  		if (emoji.replace_mode == 'google'   && emoji.allow_native && emoji.data[idx][2]) return emoji.data[idx][2];  		var img = emoji.data[idx][7] || emoji.img_path+idx+'.png';  		var title = emoji.include_title ? ' title="'+(actual || emoji.data[idx][3][0])+'"' : '';  		var text  = emoji.include_text  ? wrapper+(actual || emoji.data[idx][3][0])+wrapper : '';  		if (emoji.supports_css) {  			var px = emoji.data[idx][4];  			var py = emoji.data[idx][5];  			if (emoji.use_sheet && px != null && py != null){  				var mul = 100 / (emoji.sheet_size - 1);  				var style = 'background: url('+emoji.sheet_path+');background-position:'+(mul*px)+'% '+(mul*py)+'%;background-size:'+emoji.sheet_size+'00%';  				return '<span class="emoji-outer emoji-sizer"><span class="emoji-inner" style="'+style+'"'+title+'>'+text+'</span></span>';  			}else if (emoji.use_css_imgs){  				return '<span class="emoji emoji-'+idx+'"'+title+'>'+text+'</span>';  			}else{  				return '<span class="emoji emoji-sizer" style="background-image:url('+img+')"'+title+'>'+text+'</span>';  			}  		}  		return '<img src="'+img+'" class="emoji" '+title+'/>';  	};    	emoji.init_emoticons = function(){  		if (emoji.inits.emoticons) return;  		emoji.init_colons(); // we require this for the emoticons map  		emoji.inits.emoticons = 1;  		  		var a = [];  		emoji.map.emoticons = {};  		for (var i in emoji.emoticons_data){  			// because we never see some characters in our text except as entities, we must do some replacing  			var emoticon = i.replace(/\&/g, '&amp;').replace(/\</g, '&lt;').replace(/\>/g, '&gt;');  			  			if (!emoji.map.colons[emoji.emoticons_data[i]]) continue;    			emoji.map.emoticons[emoticon] = emoji.map.colons[emoji.emoticons_data[i]];  			a.push(emoji.escape_rx(emoticon));  		}  		emoji.rx_emoticons = new RegExp(('(^|\\s)('+a.join('|')+')(?=$|[\\s|\\?\\.,!])'), 'g');  	};  	emoji.init_colons = function(){  		if (emoji.inits.colons) return;  		emoji.inits.colons = 1;  		emoji.rx_colons = new RegExp('\:[^\\s:]+\:', 'g');  		emoji.map.colons = {};  		for (var i in emoji.data){  			for (var j=0; j<emoji.data[i][3].length; j++){  				emoji.map.colons[emoji.data[i][3][j]] = i;  			}  		}  	};  	emoji.init_unified = function(){  		if (emoji.inits.unified) return;  		emoji.inits.unified = 1;    		var a = [];  		emoji.map.unified = {};    		for (var i in emoji.data){  			for (var j=0; j<emoji.data[i][0].length; j++){  				a.push(emoji.data[i][0][j]);  				emoji.map.unified[emoji.data[i][0][j]] = i;  			}  		}    		emoji.rx_unified = new RegExp('('+a.join('|')+')', "g");  	};  	emoji.init_env = function(){  		if (emoji.inits.env) return;  		emoji.inits.env = 1;  		emoji.replace_mode = 'img';  		emoji.supports_css = false;  		var ua = navigator.userAgent;  		if (window.getComputedStyle){  			var st = window.getComputedStyle(document.body);  			if (st['background-size'] || st['backgroundSize']){  				emoji.supports_css = true;  			}  		}  		if (ua.match(/(iPhone|iPod|iPad|iPhone\s+Simulator)/i)){  			if (ua.match(/OS\s+[12345]/i)){  				emoji.replace_mode = 'softbank';  				return;  			}  			if (ua.match(/OS\s+[6789]/i)){  				emoji.replace_mode = 'unified';  				return;  			}  		}  		if (ua.match(/Mac OS X 10[._ ][789]/i)){  			if (!ua.match(/Chrome/i)){  				emoji.replace_mode = 'unified';  				return;  			}  		}  		// Need a better way to detect android devices that actually  		// support emoji.  		if (false && ua.match(/Android/i)){  			emoji.replace_mode = 'google';  			return;  		}  		if (emoji.supports_css){  			emoji.replace_mode = 'css';  		}  		// nothing fancy detected - use images  	};  	emoji.escape_rx = function(text) {  		return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");  	};  	emoji.sheet_size = #SHEET-SIZE#;  	emoji.data = #DATA#;  	emoji.emoticons_data = #DATA2#;    if (typeof exports === 'object') {    module.exports = emoji;  } else if (typeof define === 'function' && define.amd) {    define(function() { return emoji; });  } else {    this.emoji = emoji;  }    }).call(function() {    return this || (typeof window !== 'undefined' ? window : global);  }());