!function(){function e(e,t,i,r){if(!e.isReadOnly()&&!e.equals(i.editable())){NEW_CKEDITOR.dom.element.setMarker(r,e,"bidi_processed",1),r=e;for(var o=i.editable();(r=r.getParent())&&!r.equals(o);)if(r.getCustomData("bidi_processed"))return e.removeStyle("direction"),void e.removeAttribute("dir");((r=i.config.useComputedState)?e.getComputedStyle("direction"):e.getStyle("direction")||e.hasAttribute("dir"))!=t&&(e.removeStyle("direction"),r?(e.removeAttribute("dir"),t!=e.getComputedStyle("direction")&&e.setAttribute("dir",t)):e.setAttribute("dir",t),i.forceNextSelectionCheck())}}function t(e,t,i){var r=e.getCommonAncestor(!1,!0);if((e=e.clone()).enlarge(i==NEW_CKEDITOR.ENTER_BR?NEW_CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS:NEW_CKEDITOR.ENLARGE_BLOCK_CONTENTS),e.checkBoundaryOfElement(r,NEW_CKEDITOR.START)&&e.checkBoundaryOfElement(r,NEW_CKEDITOR.END)){for(var o;r&&r.type==NEW_CKEDITOR.NODE_ELEMENT&&(o=r.getParent())&&1==o.getChildCount()&&!(r.getName()in t);)r=o;return r.type==NEW_CKEDITOR.NODE_ELEMENT&&r.getName()in t&&r}}function i(i){return{context:"p",allowedContent:{"h1 h2 h3 h4 h5 h6 table ul ol blockquote div tr p div li td":{propertiesOnly:!0,attributes:"dir"}},requiredContent:"p[dir]",refresh:function(e,t){var i,r=e.config.useComputedState;if(!r){i=t.lastElement;for(var o=e.editable();i&&!(i.getName()in a)&&!i.equals(o);){var n=i.getParent();if(!n)break;i=n}}(i=i||t.block||t.blockLimit).equals(e.editable())&&(o=e.getSelection().getRanges()[0].getEnclosedNode())&&o.type==NEW_CKEDITOR.NODE_ELEMENT&&(i=o),i&&(r=r?i.getComputedStyle("direction"):i.getStyle("direction")||i.getAttribute("dir"),e.getCommand("bidirtl").setState("rtl"==r?NEW_CKEDITOR.TRISTATE_ON:NEW_CKEDITOR.TRISTATE_OFF),e.getCommand("bidiltr").setState("ltr"==r?NEW_CKEDITOR.TRISTATE_ON:NEW_CKEDITOR.TRISTATE_OFF)),(r=(t.block||t.blockLimit||e.editable()).getDirection(1))!=(e._.selDir||e.lang.dir)&&(e._.selDir=r,e.fire("contentDirChanged",r))},exec:function(r){var a=r.getSelection(),E=r.config.enterMode;if((s=a.getRanges())&&s.length){for(var d,l={},c=a.createBookmarks(),s=s.createIterator(),N=0;d=s.getNextRange(1);){var u=d.getEnclosedNode();u&&(!u||u.type==NEW_CKEDITOR.NODE_ELEMENT&&u.getName()in n)||(u=t(d,o,E)),u&&e(u,i,r,l);var g=new NEW_CKEDITOR.dom.walker(d),T=c[N].startNode,_=c[N++].endNode;for(g.evaluator=function(e){var t,i=E==NEW_CKEDITOR.ENTER_P?"p":"div";return(t=!!e&&e.type==NEW_CKEDITOR.NODE_ELEMENT&&e.getName()in o)&&((i=e.is(i))&&(i=!!(i=e.getParent())&&i.type==NEW_CKEDITOR.NODE_ELEMENT),t=!(i&&e.getParent().is("blockquote"))),!!(t&&e.getPosition(T)&NEW_CKEDITOR.POSITION_FOLLOWING&&(e.getPosition(_)&NEW_CKEDITOR.POSITION_PRECEDING+NEW_CKEDITOR.POSITION_CONTAINS)==NEW_CKEDITOR.POSITION_PRECEDING)};u=g.next();)e(u,i,r,l);for((d=d.createIterator()).enlargeBr=E!=NEW_CKEDITOR.ENTER_BR;u=d.getNextParagraph(E==NEW_CKEDITOR.ENTER_P?"p":"div");)e(u,i,r,l)}NEW_CKEDITOR.dom.element.clearAllMarkers(l),r.forceNextSelectionCheck(),a.selectBookmarks(c),r.focus()}}}}function r(e){var t=e==E.setAttribute,i=e==E.removeAttribute,r=/\bdirection\s*:\s*(.*?)\s*(:?$|;)/;return function(o,n){if(!this.isReadOnly()){var a;if(a=o==(t||i?"dir":"direction")||"style"==o&&(i||r.test(n))){e:{for(var E=(a=this).getDocument().getBody().getParent();a;){if(a.equals(E)){a=!1;break e}a=a.getParent()}a=!0}a=!a}if(a&&(a=this.getDirection(1),E=e.apply(this,arguments),a!=this.getDirection(1)))return this.getDocument().fire("dirChanged",this),E}return e.apply(this,arguments)}}var o={table:1,ul:1,ol:1,blockquote:1,div:1},n={},a={};NEW_CKEDITOR.tools.extend(n,o,{tr:1,p:1,div:1,li:1}),NEW_CKEDITOR.tools.extend(a,n,{td:1}),NEW_CKEDITOR.plugins.add("bidi",{lang:"af,ar,az,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,es-mx,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,oc,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn",icons:"bidiltr,bidirtl",hidpi:!0,init:function(e){function t(t,i,r,o,n){e.addCommand(r,new NEW_CKEDITOR.command(e,o)),e.ui.addButton&&e.ui.addButton(t,{isToggle:!0,label:i,command:r,toolbar:"bidi,"+n})}if(!e.blockless){var r=e.lang.bidi;t("BidiLtr",r.ltr,"bidiltr",i("ltr"),10),t("BidiRtl",r.rtl,"bidirtl",i("rtl"),20),e.on("contentDom",(function(){e.document.on("dirChanged",(function(t){e.fire("dirChanged",{node:t.data,dir:t.data.getDirection(1)})}))})),e.on("contentDirChanged",(function(t){t=(e.lang.dir!=t.data?"add":"remove")+"Class";var i=e.ui.space(e.config.toolbarLocation);i&&i[t]("edi_mixed_dir_content")}))}}});for(var E=NEW_CKEDITOR.dom.element.prototype,d=["setStyle","removeStyle","setAttribute","removeAttribute"],l=0;l<d.length;l++)E[d[l]]=NEW_CKEDITOR.tools.override(E[d[l]],r)}();