// Class: lime.text.unifill.Unifill

var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this

$global.Object.defineProperty(exports, "__esModule", {value: true});

var __map_reserved = {};

// Imports

var $hxClasses = require("./../../../hxClasses_stub").default;
var $import = require("./../../../import_stub").default;
function lime_text_unifill_InternalEncoding() {return require("./../../../lime/text/unifill/InternalEncoding");}
function lime_text_unifill_InternalEncodingIter() {return require("./../../../lime/text/unifill/InternalEncodingIter");}
function lime_text_unifill_CodePointIter() {return require("./../../../lime/text/unifill/CodePointIter");}
function lime_text_unifill__$Utf16_Utf16Impl() {return require("./../../../lime/text/unifill/_Utf16/Utf16Impl");}

// Constructor

var Unifill = function(){}

// Meta

Unifill.__name__ = ["lime","text","unifill","Unifill"];
Unifill.prototype = {
	
};
Unifill.prototype.__class__ = Unifill.prototype.constructor = $hxClasses["lime.text.unifill.Unifill"] = Unifill;

// Init



// Statics

Unifill.uLength = function(s) {
	return (lime_text_unifill_InternalEncoding().default).codePointCount(s,0,s.length);
}
Unifill.uCharAt = function(s,index) {
	var i = (lime_text_unifill_InternalEncoding().default).offsetByCodePoints(s,0,index);
	return (lime_text_unifill_InternalEncoding().default).charAt(s,i);
}
Unifill.uCharCodeAt = function(s,index) {
	var i = (lime_text_unifill_InternalEncoding().default).offsetByCodePoints(s,0,index);
	return (lime_text_unifill_InternalEncoding().default).codePointAt(s,i);
}
Unifill.uCodePointAt = function(s,index) {
	return Unifill.uCharCodeAt(s,index);
}
Unifill.uIndexOf = function(s,value,startIndex) {
	if(startIndex == null) {
		startIndex = 0;
	}
	var index = s.indexOf(value,(lime_text_unifill_InternalEncoding().default).offsetByCodePoints(s,0,startIndex));
	if(index >= 0) {
		return (lime_text_unifill_InternalEncoding().default).codePointCount(s,0,index);
	} else {
		return -1;
	}
}
Unifill.uLastIndexOf = function(s,value,startIndex) {
	if(startIndex == null) {
		startIndex = s.length - 1;
	}
	var index = s.lastIndexOf(value,(lime_text_unifill_InternalEncoding().default).offsetByCodePoints(s,0,startIndex));
	if(index >= 0) {
		return (lime_text_unifill_InternalEncoding().default).codePointCount(s,0,index);
	} else {
		return -1;
	}
}
Unifill.uSplit = function(s,delimiter) {
	if(delimiter.length == 0) {
		var _g = [];
		var i = new (lime_text_unifill_InternalEncodingIter().default)(s,0,s.length);
		while(i.hasNext()) {
			var i1 = i.next();
			_g.push((lime_text_unifill_InternalEncoding().default).charAt(s,i1));
		}
		return _g;
	} else {
		return s.split(delimiter);
	}
}
Unifill.uSubstr = function(s,startIndex,length) {
	var si = (lime_text_unifill_InternalEncoding().default).offsetByCodePoints(s,startIndex >= 0 ? 0 : s.length,startIndex);
	var ei = length == null ? s.length : length < 0 ? si : (lime_text_unifill_InternalEncoding().default).offsetByCodePoints(s,si,length);
	return s.substring(si,ei);
}
Unifill.uSubstring = function(s,startIndex,endIndex) {
	var si = startIndex < 0 ? 0 : (lime_text_unifill_InternalEncoding().default).offsetByCodePoints(s,0,startIndex);
	var ei = endIndex == null ? s.length : endIndex < 0 ? 0 : (lime_text_unifill_InternalEncoding().default).offsetByCodePoints(s,0,endIndex);
	return s.substring(si,ei);
}
Unifill.uIterator = function(s) {
	return new (lime_text_unifill_CodePointIter().default)(s);
}
Unifill.uCompare = function(a,b) {
	var aiter = new (lime_text_unifill_InternalEncodingIter().default)(a,0,a.length);
	var biter = new (lime_text_unifill_InternalEncodingIter().default)(b,0,b.length);
	while(aiter.hasNext() && biter.hasNext()) {
		var acode = (lime_text_unifill_InternalEncoding().default).codePointAt(a,aiter.next());
		var bcode = (lime_text_unifill_InternalEncoding().default).codePointAt(b,biter.next());
		if(acode < bcode) {
			return -1;
		}
		if(acode > bcode) {
			return 1;
		}
	}
	if(biter.hasNext()) {
		return -1;
	}
	if(aiter.hasNext()) {
		return 1;
	}
	return 0;
}
Unifill.uToString = function(codePoints) {
	return (lime_text_unifill_InternalEncoding().default).fromCodePoints(codePoints);
}
Unifill.uAddChar = function(sb,c) {
	(lime_text_unifill__$Utf16_Utf16Impl().default).encode_code_point(function(c1) {
		sb.addChar(c1);
	},c);
}


// Export

exports.default = Unifill;