function serviceHeader(){return new ServiceHeader(30,"Papago","Naver Papago is a multilingual machine translation cloud service provided by Naver Corporation."+Const.NL2+serviceHost()+Const.NL2+"\u00a9 NAVER Corp.",Capability.TRANSLATE|Capability.DETECT_LANGUAGE)}function serviceHost(a,b,d){return"https://papago.naver.com"}function serviceLink(a,b,d){var c=serviceHost();a&&(c+=format("/?sk={0}&tk={1}&st={2}",codeFromLanguage(b),codeFromLanguage(d),encodeGetParam(a)));return c}
function btoa(a){for(var b,d,c,e="",f=0,g=a.length%3;f<a.length;){if(255<(b=a.charCodeAt(f++))||255<(d=a.charCodeAt(f++))||255<(c=a.charCodeAt(f++)))return-1;b=b<<16|d<<8|c;e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(b>>18&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(b>>12&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(b>>6&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(b&
63)}return g?e.slice(0,g-3)+"===".substring(g):e}
function btoaUnicode(a){for(var b="",d=0;a.length>d;d++){var c=a.charCodeAt(d);128>c?b+=String.fromCharCode(c):2048>c?b+=String.fromCharCode(192|c>>6)+String.fromCharCode(128|63&c):55296>c||57344<=c?b+=String.fromCharCode(224|c>>12)+String.fromCharCode(128|c>>6&63)+String.fromCharCode(128|63&c):(c=65536+((1023&c)<<10|1023&a.charCodeAt(++d)),b+=String.fromCharCode(240|c>>18)+String.fromCharCode(128|c>>12&63)+String.fromCharCode(128|c>>6&63)+String.fromCharCode(128|63&c))}return btoa(b)}
function salt(a){return a.replace(/([a-m])|([n-z])/gi,function(a,d,c){return String.fromCharCode(d?d.charCodeAt(0)+13:c?c.charCodeAt(0)-13:0)||a})}function encode(a){a=btoaUnicode(a);a=salt(a.slice(0,16))+a.slice(16);return encodeURIComponent(a)}function isN2MT(a,b){return-1==="deen|ende|enhi|enpt|enzh-CN|enzh-TW|esja|hien|jaes|jako|koja|pten|zh-CNen|zh-TWen".indexOf(a+b)}
SupportedLanguages=[-1,"auto",-1,-1,-1,-1,-1,-1,-1,-1,-1,"zh-CN","zh-TW",-1,-1,-1,-1,"en",-1,-1,-1,"fr",-1,"de",-1,-1,-1,"hi",-1,-1,"id",-1,-1,"ja",-1,"ko",-1,-1,-1,-1,-1,-1,-1,-1,"pt",-1,"ru",-1,-1,-1,"es",-1,-1,"th",-1,-1,-1,"vi",-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];
function serviceDetectLanguageRequest(a){a.length>Const.MAX_QUERY_LEN&&(a=a.slice(0,Const.MAX_QUERY_LEN));a=stringifyJSON({query:a});a="data="+encode(a);var b=postHeader();return new RequestData(HttpMethod.POST,"/apis/langs/dect",a,b)}function serviceDetectLanguageResponse(a){return(a=parseJSON(a))&&a.langCode?languageFromCode(a.langCode):UNKNOWN_LANGUAGE}
function serviceTranslateRequest(a,b,d){a=prepareSource(a);a.length>Const.MAX_QUERY_LEN&&(a=a.slice(0,Const.MAX_QUERY_LEN));b=codeFromLanguage(b);d=codeFromLanguage(d);-1<"de|pt|hi".indexOf(b)&&(b=codeFromLanguage(ENGLISH_LANGUAGE));-1<"de|pt|hi".indexOf(d)&&(d=codeFromLanguage(ENGLISH_LANGUAGE));var c=isN2MT(b,d)?"n2mt":"nsmt",c=format("/apis/{0}/translate",c);a=stringifyJSON({dictDisplay:30,source:b,target:d,text:a});a="data="+encode(a);b=postHeader();return new RequestData(HttpMethod.POST,c,a,
b)}function serviceTranslateResponse(a,b,d,c){a=parseJSON(b);return new ResponseData(a&&a.translatedText?a.translatedText:"",d,c)};
