!function(){function e(e){CKEDITOR.tools.extend(this,e),this.queue=[],this.init?this.init(CKEDITOR.tools.bind((function(){for(var e;e=this.queue.pop();)e.call(this);this.ready=!0}),this)):this.ready=!0}CKEDITOR.plugins.add("codesnippet",{requires:"widget,dialog",lang:"ar,az,bg,ca,cs,da,de,de-ch,el,en,en-au,en-gb,eo,es,es-mx,et,eu,fa,fi,fr,fr-ca,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,th,tr,tt,ug,uk,vi,zh,zh-cn",icons:"codesnippet",hidpi:!0,isSupportedEnvironment:function(){return!CKEDITOR.env.ie||8<CKEDITOR.env.version},beforeInit:function(e){e._.codesnippet={},this.setHighlighter=function(t){e._.codesnippet.highlighter=t,t=e._.codesnippet.langs=e.config.codeSnippet_languages||t.languages,e._.codesnippet.langsRegex=new RegExp("(?:^|\\s)language-("+CKEDITOR.tools.object.keys(t).join("|")+")(?:\\s|$)")},e.once("pluginsLoaded",(function(){this.setHighlighter=null}),this)},onLoad:function(){CKEDITOR.dialog.add("codeSnippet",this.path+"dialogs/codesnippet.js")},init:function(e){e.ui.addButton&&e.ui.addButton("CodeSnippet",{label:e.lang.codesnippet.button,command:"codeSnippet",toolbar:"insert,10"})},afterInit:function(e){var t=this.path;if(function(e){var t=e.config.codeSnippet_codeClass,i=/\r?\n/g,n=new CKEDITOR.dom.element("textarea");e.widgets.add("codeSnippet",{allowedContent:"pre; code(language-*)",requiredContent:"pre",styleableElements:"pre",template:'<pre><code class="'+t+'"></code></pre>',dialog:"codeSnippet",pathName:e.lang.codesnippet.pathName,mask:!0,parts:{pre:"pre",code:"code"},highlight:function(){var t=this,n=this.data,s=function(n){t.parts.code.setHtml(e.plugins.codesnippet.isSupportedEnvironment()?n:n.replace(i,"<br>"))};s(CKEDITOR.tools.htmlEncode(n.code)),e._.codesnippet.highlighter.highlight(n.code,n.lang,(function(t){e.fire("lockSnapshot"),s(t),e.fire("unlockSnapshot")}))},data:function(){var e=this.data,t=this.oldData;e.code&&this.parts.code.setHtml(CKEDITOR.tools.htmlEncode(e.code)),t&&e.lang!=t.lang&&this.parts.code.removeClass("language-"+t.lang),e.lang&&(this.parts.code.addClass("language-"+e.lang),this.highlight()),this.oldData=CKEDITOR.tools.copy(e)},upcast:function(i,o){if("pre"==i.name){for(var a,h=[],l=i.children,p=l.length-1;0<=p;p--)(a=l[p]).type==CKEDITOR.NODE_TEXT&&a.value.match(s)||h.push(a);var c;if(1==h.length&&"code"==(c=h[0]).name&&1==c.children.length&&c.children[0].type==CKEDITOR.NODE_TEXT)return(h=e._.codesnippet.langsRegex.exec(c.attributes.class))&&(o.lang=h[1]),n.setHtml(c.getHtml()),o.code=n.getValue(),c.addClass(t),i}},downcast:function(e){var i=e.getFirst("code");return i.children.length=0,i.removeClass(t),i.add(new CKEDITOR.htmlParser.text(CKEDITOR.tools.htmlEncode(this.data.code))),e}});var s=/^[\s\n\r]*$/}(e),!e._.codesnippet.highlighter){var i=new CKEDITOR.plugins.codesnippet.highlighter({languages:{apache:"Apache",bash:"Bash",coffeescript:"CoffeeScript",cpp:"C++",cs:"C#",css:"CSS",diff:"Diff",html:"HTML",http:"HTTP",ini:"INI",java:"Java",javascript:"JavaScript",json:"JSON",makefile:"Makefile",markdown:"Markdown",nginx:"Nginx",objectivec:"Objective-C",perl:"Perl",php:"PHP",python:"Python",ruby:"Ruby",sql:"SQL",vbscript:"VBScript",xhtml:"XHTML",xml:"XML"},init:function(i){var n=this;e.plugins.codesnippet.isSupportedEnvironment()&&CKEDITOR.scriptLoader.load(t+"lib/highlight/highlight.pack.js",(function(){n.hljs=window.hljs,i()})),e.addContentsCss&&e.addContentsCss(t+"lib/highlight/styles/"+e.config.codeSnippet_theme+".css")},highlighter:function(e,t,i){(e=this.hljs.highlightAuto(e,this.hljs.getLanguage(t)?[t]:void 0))&&i(e.value)}});this.setHighlighter(i)}}}),CKEDITOR.plugins.codesnippet={highlighter:e},e.prototype.highlight=function(){var e=arguments;this.ready?this.highlighter.apply(this,e):this.queue.push((function(){this.highlighter.apply(this,e)}))}}(),CKEDITOR.config.codeSnippet_codeClass="hljs",CKEDITOR.config.codeSnippet_theme="default";