var Const={MAX_URI_LEN:1800,MAX_QUERY_LEN:5E3,NL:"\r\n",NL2:"\r\n\r\n"},Capability={TRANSLATE:1,DETECT_LANGUAGE:2,LISTEN:4,DICTIONARY:8},HttpMethod={UNDEFINED:0,GET:1,POST:2},CodePage={WINDOWS1251:1251,UTF8:65001,ISO8859_1:28591},toString=Object.prototype.toString,isArray=Array.isArray||function(a){return"[object Array]"===toString.call(a)};function ServiceHeader(a,b,c,d){this.id=a;this.name=b||"";this.info=c||"";this.capabilities=d}
function RequestData(a,b,c,d,e,g){this.method=a;this.uri=b||"";this.data=c||"";this.headers=d||(a===HttpMethod.UNDEFINED?"":a===HttpMethod.GET?getHeader():postHeader());this.codepage=e||CodePage.UTF8;this.responseHandler=g||""}function ResponseData(a,b,c,d,e){this.translation=a||"";this.sourceLanguage=b;this.translationLanguage=c;this.data=d||"";this.nextRequestHandler=e||""}var Options={};function addOption(a,b){Options[a]=b}
function getHeader(){var a=format("Accept-Language: {0};q=0.8,en-US;q=0.6,en;q=0.4",Options.LanguageCode);return"Accept: */*"+Const.NL+a+Const.NL+"Accept-Encoding: gzip,deflate"+Const.NL+"Accept-Charset: utf-8"}function postHeader(a){a=a?"application/json":"application/x-www-form-urlencoded";return getHeader()+Const.NL+"Content-Type: "+a+"; charset=utf-8"}function encodeUriParam(a){return a?encodeURIComponent(a):""}
function encodeGetParam(a){a=encodeUriParam(a);if(a.length>Const.MAX_URI_LEN){a=a.slice(0,Const.MAX_URI_LEN);var b=a.lastIndexOf("%20");if(0<b)return a.slice(0,b)}return a}function encodePostParam(a){return encodeUriParam(a)}function prepareSource(a){return(a||"").replace(/(\r\n|\r)/g,"\n")}function format(){for(var a=arguments[0],b=0;b<arguments.length-1;b++)a=a.replace(new RegExp("\\{"+b+"\\}","gm"),arguments[b+1]);return a}
function stringFind(a,b){if(b)if("string"===typeof b){var c=a.indexOf(b);if(-1<c)return{index:c,length:b.length}}else if(c=a.match(b))return{index:c.index,length:c[0].length}}function stringFindSub(a,b,c,d,e){return a&&b&&d&&(b=stringFind(a,b))&&(a=a.slice(c?b.index:b.index+b.length),b=stringFind(a,d))?a.slice(0,e?b.index+b.length:b.index):""}function trimString(a){return a?a.replace(/(^\s+)|(\s+$)/g,""):""}function startsWith(a,b){return a.slice(0,b.length)===b}
function endsWith(a,b){return-1!==a.indexOf(b,a.length-b.length)}function removeIfStartsWith(a,b){return startsWith(a,b)?a.slice(b.length):a}var IE_SPLIT_ISSUE=3!=="a'b".split(/(')/g).length;function stringSplit(a,b){if(!IE_SPLIT_ISSUE)return a.split(b);var c=[];b.global=!0;for(var d=b.exec(a);d;){c.push(a.substring(0,d.index));for(var e=1,g=d.length;e<g;e++)c.push(d[e]);a=a.substring(b.lastIndex,a.length);d=b.exec(a)}c.push(a);return c}
function unquoteHtml(a){if(!a)return"";a=a.replace(/&amp[;]?/g,"&");a=a.replace(/&lt[;]?/g,"<");a=a.replace(/&gt[;]?/g,">");a=a.replace(/&quot[;]?/g,'"');return a=a.replace(/&#[0]?39[;]/g,"'")}function removeEmptyLines(a){if(!a)return"";a=a.replace(/\r/gi,"");a=a.split("\n");for(var b=0;b<a.length;b++)a[b].match(/[\S]/g)||(a[b]="");a=a.join("\n").replace(/\n{3,}/g,"\n\n");a=a.replace(/\n/gi,Const.NL);return trimString(a)}
function stripHtml(a){if(!a)return"";a=a.replace(/\x3c!--[\s\S]*?--\x3e/g,"");a=a.replace(/<(style|script)(.|\s)*?(style|script)>/g,"");a=a.replace(/<br\/>/gi,Const.NL);a=a.replace(/<[^>]+>/g,"");a=a.replace(/&nbsp;/g," ");return removeEmptyLines(a)}function regExpRemove(a,b,c){if(!b)return a;b=format(c,b.join("|"));return a.replace(new RegExp(b,"g"),"")}function removeAttributes(a,b){return regExpRemove(a,b," ({0})(?:\\s*=\\s*(?:(?:\"((?:\\.|[^\"])*)\")|(?:'((?:\\.|[^'])*)')|([^>\\s]+)))?")}
function removeTags(a,b){return regExpRemove(a,b,"</?({0})[^>]*>")}function removeElements(a,b){return regExpRemove(a,b,"<\\s*({0})[^>]*>((.|\n)*?)<\\s*/\\s*({0})>")}
function updateHtmlLinks(a,b){if(!a)return"";var c=startsWith(b,"https")?"https://":"http://";b=removeIfStartsWith(b,c);endsWith(b,"/")||(b+="/");a=a.replace(/href="\/\//gi,'href="'+c);a=a.replace(/href="\//gi,'href="'+c+b);a=a.replace(/src="\/\//gi,'src="'+c);a=a.replace(/src="\//gi,'src="'+c+b);a=a.replace(/href='\/\//gi,"href='"+c);a=a.replace(/href='\//gi,"href='"+c+b);a=a.replace(/src='\/\//gi,"src='"+c);return a=a.replace(/src='\//gi,"src='"+c+b)}
var SupportedLanguages=null,UNKNOWN_LANGUAGE_CODE=-1,UNKNOWN_LANGUAGE=0,AUTO_DETECT_LANGUAGE=1,ENGLISH_LANGUAGE=17;function isLanguage(a){return a>AUTO_DETECT_LANGUAGE&&a<SupportedLanguages.length}function codeFromLanguage(a){return a===AUTO_DETECT_LANGUAGE||isLanguage(a)?SupportedLanguages[a]:UNKNOWN_LANGUAGE_CODE}
function languageFromCode(a){if(SupportedLanguages[ENGLISH_LANGUAGE]===a)return ENGLISH_LANGUAGE;for(var b=AUTO_DETECT_LANGUAGE;b<SupportedLanguages.length;b++)if(SupportedLanguages[b]===a)return b;return UNKNOWN_LANGUAGE}function usesAutoDetectCode(){return SupportedLanguages[AUTO_DETECT_LANGUAGE]!==UNKNOWN_LANGUAGE_CODE}function parseJSON(a){return(new Function("return "+a))()}
var stringifyJSON=function(){var a={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},b=function(b){return a[b]||"\\u"+(b.charCodeAt(0)+65536).toString(16).substr(1)},c=/[\\"\u0000-\u001F\u2028\u2029]/g;return function e(a){if(null===a)return"null";if("number"===typeof a)return isFinite(a)?a.toString():"null";if("boolean"===typeof a)return a.toString();if("object"===typeof a){if("function"===typeof a.toJSON)return e(a.toJSON());if(isArray(a)){for(var h="[",f=0;f<a.length;f++)h+=
(f?", ":"")+e(a[f]);return h+"]"}if("[object Object]"===toString.call(a)){h=[];for(f in a)a.hasOwnProperty(f)&&h.push(e(f)+": "+e(a[f]));return"{"+h.join(", ")+"}"}}return'"'+a.toString().replace(c,b)+'"'}}();Array.prototype.map||(Array.prototype.map=function(a){for(var b=Object(this),c=b.length>>>0,d=Array(c),e=0;e<c;)e in b&&(d[e]=a(b[e],e,b)),e++;return d});Array.prototype.forEach||(Array.prototype.forEach=function(a){for(var b=Object(this),c=b.length>>>0,d=0;d<c;)d in b&&a(b[d],d,b),d++});
Array.prototype.filter||(Array.prototype.filter=function(a){for(var b=Object(this),c=b.length>>>0,d=0,e=[],g;d<c;)d in b&&(g=b[d],a(g,d,b)&&e.push(g)),d++;return e});
