/*
 Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
CKEDITOR.plugins.add("colorbutton",{requires:"panelbutton,floatpanel",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:"bgcolor,textcolor",hidpi:!0,init:function(d){function w(a){var u=a.name,f=a.type,h=a.title,v=a.order,t=a.commandName;a=a.contentTransformations||{};var p=new CKEDITOR.style(k["colorButton_"+
f+"Style"]),q=CKEDITOR.tools.getNextId()+"_colorBox",r={type:f},l=new CKEDITOR.style(k["colorButton_"+f+"Style"],{color:"inherit"}),n;d.addCommand(t,{contextSensitive:!0,exec:function(a,b){if(!a.readOnly){var c=b.newStyle;a.removeStyle(l);a.focus();c&&a.applyStyle(c);a.fire("saveSnapshot")}},refresh:function(a,b){l.checkApplicable(b,a,a.activeFilter)?l.checkActive(b,a)?this.setState(CKEDITOR.TRISTATE_ON):this.setState(CKEDITOR.TRISTATE_OFF):this.setState(CKEDITOR.TRISTATE_DISABLED)}});d.ui.add(u,
CKEDITOR.UI_PANELBUTTON,{label:h,title:h,command:t,editorFocus:0,toolbar:"colors,"+v,allowedContent:p,requiredContent:p,contentTransformations:a,panel:{css:CKEDITOR.skin.getPath("editor"),attributes:{role:"listbox","aria-label":g.panelTitle}},select:function(a){var b=k.colorButton_colors.split(",");a=CKEDITOR.tools.array.find(b,a);a=m(a);x(n,a);n._.markFirstDisplayed()},onBlock:function(a,b){n=b;b.autoSize=!0;b.element.addClass("cke_colorblock");b.element.setHtml(B({type:f,colorBoxId:q,colorData:r,
commandName:t}));b.element.getDocument().getBody().setStyle("overflow","hidden");CKEDITOR.ui.fire("ready",this);var c=b.keys,e="rtl"==d.lang.dir;c[e?37:39]="next";c[40]="next";c[9]="next";c[e?39:37]="prev";c[38]="prev";c[CKEDITOR.SHIFT+9]="prev";c[32]="click"},onOpen:function(){var a=d.getSelection(),b=a&&a.getStartElement(),c=d.elementPath(b);if(!c)return null;b=c.block||c.blockLimit||d.document.getBody();do c=b&&b.getComputedStyle("back"==f?"background-color":"color")||"transparent";while("back"==
f&&"transparent"==c&&b&&(b=b.getParent()));c&&"transparent"!=c||(c="#ffffff");!1!==k.colorButton_enableAutomatic&&this._.panel._.iframe.getFrameDocument().getById(q).setStyle("background-color",c);if(b=a&&a.getRanges()[0]){for(var a=new CKEDITOR.dom.walker(b),e=b.collapsed?b.startContainer:a.next(),b="";e;){e.type!==CKEDITOR.NODE_ELEMENT&&(e=e.getParent());e=m(e.getComputedStyle("back"==f?"background-color":"color"));b=b||e;if(b!==e){b="";break}e=a.next()}"transparent"==b&&(b="");"fore"==f&&(r.automaticTextColor=
"#"+m(c));r.selectionColor=b?"#"+b:"";x(n,b)}return c}})}function B(a){function u(a){a=a&&new CKEDITOR.style(n,{color:a});d.execCommand(t,{newStyle:a})}var f=a.type,h=a.colorBoxId,v=a.colorData,t=a.commandName;a=[];var p=k.colorButton_colors.split(","),q=k.colorButton_colorsPerRow||6,r=d.plugins.colordialog&&!1!==k.colorButton_enableMore,l=p.length+(r?2:1),n=d.config["colorButton_"+f+"Style"];n.childRule="back"==f?function(a){return y(a)}:function(a){return!(a.is("a")||a.getElementsByTag("a").count())||
y(a)};var m=CKEDITOR.tools.addFunction(function(a){d.focus();d.fire("saveSnapshot");"?"==a?d.getColorFromDialog(function(a){a&&u(a)},null,v):u(a&&"#"+a)});!1!==k.colorButton_enableAutomatic&&a.push('\x3ca class\x3d"cke_colorauto" _cke_focus\x3d1 hidefocus\x3dtrue title\x3d"',g.auto,'" draggable\x3d"false" ondragstart\x3d"return false;" onclick\x3d"CKEDITOR.tools.callFunction(',m,",null,'",f,"');return false;\" href\x3d\"javascript:void('",g.auto,'\')" role\x3d"option" aria-posinset\x3d"1" aria-setsize\x3d"',
l,'"\x3e\x3ctable role\x3d"presentation" cellspacing\x3d0 cellpadding\x3d0 width\x3d"100%"\x3e\x3ctr\x3e\x3ctd colspan\x3d"'+q+'" align\x3d"center"\x3e\x3cspan class\x3d"cke_colorbox" id\x3d"',h,'"\x3e\x3c/span\x3e',g.auto,"\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e\x3c/a\x3e");a.push('\x3ctable role\x3d"presentation" cellspacing\x3d0 cellpadding\x3d0 width\x3d"100%"\x3e');for(h=0;h<p.length;h++){0===h%q&&a.push("\x3c/tr\x3e\x3ctr\x3e");var b=p[h].split("/"),c=b[0],e=b[1]||c;a.push('\x3ctd\x3e\x3ca class\x3d"cke_colorbox" _cke_focus\x3d1 hidefocus\x3dtrue title\x3d"',
b[1]?c:d.lang.colorbutton.colors[e]||e,'" draggable\x3d"false" ondragstart\x3d"return false;" onclick\x3d"CKEDITOR.tools.callFunction(',m,",'",e,"','",f,"'); return false;\" href\x3d\"javascript:void('",e,'\')" data-value\x3d"'+e+'" role\x3d"option" aria-posinset\x3d"',h+2,'" aria-setsize\x3d"',l,'"\x3e\x3cspan class\x3d"cke_colorbox" style\x3d"background-color:#',e,'"\x3e\x3c/span\x3e\x3c/a\x3e\x3c/td\x3e')}r&&a.push('\x3c/tr\x3e\x3ctr\x3e\x3ctd colspan\x3d"'+q+'" align\x3d"center"\x3e\x3ca class\x3d"cke_colormore" _cke_focus\x3d1 hidefocus\x3dtrue title\x3d"',
g.more,'" draggable\x3d"false" ondragstart\x3d"return false;" onclick\x3d"CKEDITOR.tools.callFunction(',m,",'?','",f,"');return false;\" href\x3d\"javascript:void('",g.more,"')\"",' role\x3d"option" aria-posinset\x3d"',l,'" aria-setsize\x3d"',l,'"\x3e',g.more,"\x3c/a\x3e\x3c/td\x3e");a.push("\x3c/tr\x3e\x3c/table\x3e");return a.join("")}function y(a){return"false"==a.getAttribute("contentEditable")||a.getAttribute("data-nostyle")}function x(a,d){for(var f=a._.getItems(),h=0;h<f.count();h++){var g=
f.getItem(h);g.removeAttribute("aria-selected");d&&d==m(g.getAttribute("data-value"))&&g.setAttribute("aria-selected",!0)}}function m(a){return CKEDITOR.tools.normalizeHex("#"+CKEDITOR.tools.convertRgbToHex(a||"")).replace(/#/g,"")}var k=d.config,g=d.lang.colorbutton;if(!CKEDITOR.env.hc){w({name:"TextColor",type:"fore",commandName:"textColor",title:g.textColorTitle,order:10,contentTransformations:[[{element:"font",check:"span{color}",left:function(a){return!!a.attributes.color},right:function(a){a.name=
"span";a.attributes.color&&(a.styles.color=a.attributes.color);delete a.attributes.color}}]]});var z,A=d.config.colorButton_normalizeBackground;if(void 0===A||A)z=[[{element:"span",left:function(a){var d=CKEDITOR.tools;if("span"!=a.name||!a.styles||!a.styles.background)return!1;a=d.style.parse.background(a.styles.background);return a.color&&1===d.object.keys(a).length},right:function(a){var g=(new CKEDITOR.style(d.config.colorButton_backStyle,{color:a.styles.background})).getDefinition();a.name=g.element;
a.styles=g.styles;a.attributes=g.attributes||{};return a}}]];w({name:"BGColor",type:"back",commandName:"bgColor",title:g.bgColorTitle,order:20,contentTransformations:z})}}});CKEDITOR.config.colorButton_colors="1ABC9C,2ECC71,3498DB,9B59B6,4E5F70,F1C40F,16A085,27AE60,2980B9,8E44AD,2C3E50,F39C12,E67E22,E74C3C,ECF0F1,95A5A6,DDD,FFF,D35400,C0392B,BDC3C7,7F8C8D,999,000";CKEDITOR.config.colorButton_foreStyle={element:"span",styles:{color:"#(color)"},overrides:[{element:"font",attributes:{color:null}}]};
CKEDITOR.config.colorButton_backStyle={element:"span",styles:{"background-color":"#(color)"}};