/*
 Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
 For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
(function(){CKEDITOR.plugins.add("language",{requires:"menubutton",lang:"ar,az,bg,ca,cs,cy,da,de,de-ch,el,en,en-au,en-gb,eo,es,es-mx,et,eu,fa,fi,fo,fr,gl,he,hr,hu,id,it,ja,km,ko,ku,lt,lv,nb,nl,no,oc,pl,pt,pt-br,ro,ru,sk,sl,sq,sr,sr-latn,sv,tr,tt,ug,uk,vi,zh,zh-cn",icons:"language",hidpi:!0,init:function(a){var c=a.config.language_list||["ar:Arabic:rtl","fr:French","es:Spanish"],f=this,d=a.lang.language,e={},h,k,l,g;a.addCommand("language",{allowedContent:"span[!lang,dir]",requiredContent:"span[lang]",
contextSensitive:!0,exec:function(b,a){var c=e["language_"+a];if(c)b[c.style.checkActive(b.elementPath(),b)?"removeStyle":"applyStyle"](c.style)},refresh:function(b){this.setState(f.getCurrentLangElement(b)?CKEDITOR.TRISTATE_ON:CKEDITOR.TRISTATE_OFF)}});for(g=0;g<c.length;g++)h=c[g].split(":"),k=h[0],l="language_"+k,e[l]={label:h[1],langId:k,group:"language",order:g,ltr:"rtl"!=(""+h[2]).toLowerCase(),onClick:function(){a.execCommand("language",this.langId)},role:"menuitemcheckbox"},e[l].style=new CKEDITOR.style({element:"span",
attributes:{lang:k,dir:e[l].ltr?"ltr":"rtl"}});e.language_remove={label:d.remove,group:"language_remove",state:CKEDITOR.TRISTATE_DISABLED,order:e.length,onClick:function(){var b=f.getCurrentLangElement(a);b&&a.execCommand("language",b.getAttribute("lang"))}};a.addMenuGroup("language",1);a.addMenuGroup("language_remove");a.addMenuItems(e);a.ui.add("Language",CKEDITOR.UI_MENUBUTTON,{label:d.button,allowedContent:"span[!lang,dir]",requiredContent:"span[lang]",toolbar:"bidi,30",command:"language",contentTransformations:[[{element:"span",
left:function(b){return b.attributes.lang&&(!b.attributes.dir||""===b.attributes.dir)},right:function(b){var a=CKEDITOR.tools.object.keys(CKEDITOR.lang.rtl),a=-1!==CKEDITOR.tools.array.indexOf(a,b.attributes.lang)?"rtl":"ltr";b.attributes.dir=a}}]],onMenu:function(){var b={},c=f.getCurrentLangElement(a),d;for(d in e)b[d]=CKEDITOR.TRISTATE_OFF;b.language_remove=c?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED;c&&(b["language_"+c.getAttribute("lang")]=CKEDITOR.TRISTATE_ON);return b}});a.addRemoveFormatFilter&&
a.addRemoveFormatFilter(function(a){return!(a.is("span")&&a.getAttribute("dir")&&a.getAttribute("lang"))})},getCurrentLangElement:function(a){var c=a.elementPath();a=c&&c.elements;var f;if(c)for(var d=0;d<a.length;d++)c=a[d],!f&&"span"==c.getName()&&c.hasAttribute("lang")&&(f=c);return f}})})();