!function(){function e(e,t,n,o){var a=new CKEDITOR.dom.walker(e);if(!(e=e.startContainer.getAscendant(t,!0)||e.endContainer.getAscendant(t,!0))||(n(e),!o))for(;(e=a.next())&&(!(e=e.getAscendant(t,!0))||(n(e),!o)););}function t(e,t){var n={ul:"ol",ol:"ul"};return-1!==o(t,(function(t){return t.element===e||t.element===n[e]}))}function n(e){this.styles=null,this.sticky=!1,this.editor=e,this.filter=new CKEDITOR.filter(e,e.config.copyFormatting_allowRules),!0===e.config.copyFormatting_allowRules&&(this.filter.disabled=!0),e.config.copyFormatting_disallowRules&&this.filter.disallow(e.config.copyFormatting_disallowRules)}var o=CKEDITOR.tools.indexOf,a=CKEDITOR.tools.getMouseButton,r=!1;CKEDITOR.plugins.add("copyformatting",{lang:"az,de,en,it,ja,nb,nl,oc,pl,pt-br,ru,sv,tr,zh,zh-cn",icons:"copyformatting",hidpi:!0,init:function(e){var n=CKEDITOR.plugins.copyformatting;n._addScreenReaderContainer(),r||(CKEDITOR.document.appendStyleSheet(this.path+"styles/copyformatting.css"),r=!0),e.addContentsCss&&e.addContentsCss(this.path+"styles/copyformatting.css"),e.copyFormatting=new n.state(e),e.addCommand("copyFormatting",n.commands.copyFormatting),e.addCommand("applyFormatting",n.commands.applyFormatting),e.ui.addButton("CopyFormatting",{label:e.lang.copyformatting.label,command:"copyFormatting",toolbar:"cleanup,0"}),e.on("contentDom",(function(){var t=e.getCommand("copyFormatting"),n=e.editable(),o=n.isInline()?n:e.document,r=e.ui.get("CopyFormatting");n.attachListener(o,"mouseup",(function(n){a(n)===CKEDITOR.MOUSE_BUTTON_LEFT&&t.state===CKEDITOR.TRISTATE_ON&&e.execCommand("applyFormatting")})),n.attachListener(CKEDITOR.document,"mouseup",(function(o){a(o)!==CKEDITOR.MOUSE_BUTTON_LEFT||t.state!==CKEDITOR.TRISTATE_ON||n.contains(o.data.getTarget())||e.execCommand("copyFormatting")})),r&&(o=CKEDITOR.document.getById(r._.id),n.attachListener(o,"dblclick",(function(){e.execCommand("copyFormatting",{sticky:!0})})),n.attachListener(o,"mouseup",(function(e){e.data.stopPropagation()})))})),e.config.copyFormatting_keystrokeCopy&&e.setKeystroke(e.config.copyFormatting_keystrokeCopy,"copyFormatting"),e.on("key",(function(t){var n=e.getCommand("copyFormatting");(t=t.data.domEvent).getKeystroke&&27===t.getKeystroke()&&n.state===CKEDITOR.TRISTATE_ON&&e.execCommand("copyFormatting")})),e.copyFormatting.on("extractFormatting",(function(t){var o=t.data.element;return o.contains(e.editable())||o.equals(e.editable())?t.cancel():(o=n._convertElementToStyleDef(o),e.copyFormatting.filter.check(new CKEDITOR.style(o),!0,!0)?void(t.data.styleDef=o):t.cancel())})),e.copyFormatting.on("applyFormatting",(function(a){if(!a.data.preventFormatStripping){var r,i,l=a.data.range,s=n._extractStylesFromRange(e,l),c=n._determineContext(l);if(e.copyFormatting._isContextAllowed(c))for(i=0;i<s.length;i++)c=s[i],r=l.createBookmark(),-1===o(n.preservedElements,c.element)?CKEDITOR.env.webkit&&!CKEDITOR.env.chrome?s[i].removeFromRange(a.data.range,a.editor):s[i].remove(a.editor):t(c.element,a.data.styles)&&n._removeStylesFromElementInRange(l,c.element),l.moveToBookmark(r)}})),e.copyFormatting.on("applyFormatting",(function(t){var n=CKEDITOR.plugins.copyformatting,o=n._determineContext(t.data.range);"list"===o&&e.copyFormatting._isContextAllowed("list")?n._applyStylesToListContext(t.editor,t.data.range,t.data.styles):"table"===o&&e.copyFormatting._isContextAllowed("table")?n._applyStylesToTableContext(t.editor,t.data.range,t.data.styles):e.copyFormatting._isContextAllowed("text")&&n._applyStylesToTextContext(t.editor,t.data.range,t.data.styles)}),null,null,999)}}),n.prototype._isContextAllowed=function(e){var t=this.editor.config.copyFormatting_allowedContexts;return!0===t||-1!==o(t,e)},CKEDITOR.event.implementOn(n.prototype),CKEDITOR.plugins.copyformatting={state:n,inlineBoundary:"h1 h2 h3 h4 h5 h6 p div".split(" "),excludedAttributes:["id","style","href","data-cke-saved-href","dir"],elementsForInlineTransform:["li"],excludedElementsFromInlineTransform:["table","thead","tbody","ul","ol"],excludedAttributesFromInlineTransform:["value","type"],preservedElements:"ul ol li td th tr thead tbody table".split(" "),breakOnElements:["ul","ol","table"],_initialKeystrokePasteCommand:null,commands:{copyFormatting:{exec:function(e,t){var n=CKEDITOR.plugins.copyformatting,o=e.copyFormatting,a=!!t&&"keystrokeHandler"==t.from,r=!!t&&(t.sticky||a),i=n._getCursorContainer(e),l=CKEDITOR.document.getDocumentElement();if(this.state===CKEDITOR.TRISTATE_ON)return o.styles=null,o.sticky=!1,i.removeClass("cke_copyformatting_active"),l.removeClass("cke_copyformatting_disabled"),l.removeClass("cke_copyformatting_tableresize_cursor"),n._putScreenReaderMessage(e,"canceled"),n._detachPasteKeystrokeHandler(e),this.setState(CKEDITOR.TRISTATE_OFF);o.styles=n._extractStylesFromElement(e,e.elementPath().lastElement),this.setState(CKEDITOR.TRISTATE_ON),a||(i.addClass("cke_copyformatting_active"),l.addClass("cke_copyformatting_tableresize_cursor"),e.config.copyFormatting_outerCursor&&l.addClass("cke_copyformatting_disabled")),o.sticky=r,n._putScreenReaderMessage(e,"copied"),n._attachPasteKeystrokeHandler(e)}},applyFormatting:{editorFocus:!(CKEDITOR.env.ie&&!CKEDITOR.env.edge),exec:function(e,t){var n=e.getCommand("copyFormatting"),o=!!t&&"keystrokeHandler"==t.from,a=CKEDITOR.plugins.copyformatting,r=e.copyFormatting,i=a._getCursorContainer(e),l=CKEDITOR.document.getDocumentElement();if(o&&!r.styles)return a._putScreenReaderMessage(e,"failed"),a._detachPasteKeystrokeHandler(e),!1;o=a._applyFormat(e,r.styles),r.sticky||(r.styles=null,i.removeClass("cke_copyformatting_active"),l.removeClass("cke_copyformatting_disabled"),l.removeClass("cke_copyformatting_tableresize_cursor"),n.setState(CKEDITOR.TRISTATE_OFF),a._detachPasteKeystrokeHandler(e)),a._putScreenReaderMessage(e,o?"applied":"canceled")}}},_getCursorContainer:function(e){return e.elementMode===CKEDITOR.ELEMENT_MODE_INLINE?e.editable():e.editable().getParent()},_convertElementToStyleDef:function(e){var t=CKEDITOR.tools,n=e.getAttributes(CKEDITOR.plugins.copyformatting.excludedAttributes);t=t.parseCssText(e.getAttribute("style"),!0,!0);return{element:e.getName(),type:CKEDITOR.STYLE_INLINE,attributes:n,styles:t}},_extractStylesFromElement:function(e,t){var n={},a=[];do{if(t.type===CKEDITOR.NODE_ELEMENT&&!t.hasAttribute("data-cke-bookmark")&&(n.element=t,e.copyFormatting.fire("extractFormatting",n,e)&&n.styleDef&&a.push(new CKEDITOR.style(n.styleDef)),t.getName&&-1!==o(CKEDITOR.plugins.copyformatting.breakOnElements,t.getName())))break}while((t=t.getParent())&&t.type===CKEDITOR.NODE_ELEMENT);return a},_extractStylesFromRange:function(e,t){for(var n,o=[],a=new CKEDITOR.dom.walker(t);n=a.next();)o=o.concat(CKEDITOR.plugins.copyformatting._extractStylesFromElement(e,n));return o},_removeStylesFromElementInRange:function(e,t){for(var n,a=-1!==o(["ol","ul","table"],t),r=new CKEDITOR.dom.walker(e);(n=r.next())&&(!(n=n.getAscendant(t,!0))||(n.removeAttributes(n.getAttributes()),!a)););},_getSelectedWordOffset:function(e){function t(e,t){return e[t?"getPrevious":"getNext"]((function(e){return e.type!==CKEDITOR.NODE_COMMENT}))}function n(e){return e.type==CKEDITOR.NODE_ELEMENT?(e=e.getHtml().replace(/<span.*?> <\/span>/g,"")).replace(/<.*?>/g,""):e.getText()}function a(e,r){var i,l,s=e,c=/\s/g,m="p br ol ul li td th div caption body".split(" "),d=!1,g=!1;do{for(i=t(s,r);!i&&s.getParent();){if(s=s.getParent(),-1!==o(m,s.getName())){g=d=!0;break}i=t(s,r)}if(i&&i.getName&&-1!==o(m,i.getName())){d=!0;break}s=i}while(s&&s.getStyle&&("none"==s.getStyle("display")||!s.getText()));for(s||(s=e);s.type!==CKEDITOR.NODE_TEXT;)s=!d||r||g?s.getChild(0):s.getChild(s.getChildCount()-1);for(m=n(s);null!=(g=c.exec(m))&&(l=g.index,r););if("number"!=typeof l&&!d)return a(s,r);if(d)r?l=0:l=(g=(c=/([\.\b]*$)/).exec(m))?g.index:m.length;else if(r&&(l+=1)>m.length)return a(s);return{node:s,offset:l}}var r,i,l,s,c,m=/\b\w+\b/gi;for(r=n(l=s=c=e.startContainer);null!=(i=m.exec(r));)if(i.index+i[0].length>=e.startOffset)return e=i.index,m=i.index+i[0].length,0===i.index&&(s=(i=a(l,!0)).node,e=i.offset),m>=r.length&&(c=(r=a(l)).node,m=r.offset),{startNode:s,startOffset:e,endNode:c,endOffset:m};return null},_filterStyles:function(e){var t,n,o=CKEDITOR.tools.isEmpty,a=[];for(n=0;n<e.length;n++)t=e[n]._.definition,-1!==CKEDITOR.tools.indexOf(CKEDITOR.plugins.copyformatting.inlineBoundary,t.element)&&(t.element=e[n].element="span"),"span"===t.element&&o(t.attributes)&&o(t.styles)||a.push(e[n]);return a},_determineContext:function(e){function t(t){var n,o=new CKEDITOR.dom.walker(e);if(e.startContainer.getAscendant(t,!0)||e.endContainer.getAscendant(t,!0))return!0;for(;n=o.next();)if(n.getAscendant(t,!0))return!0}return t({ul:1,ol:1})?"list":t("table")?"table":"text"},_applyStylesToTextContext:function(e,t,n){var a,r,i=CKEDITOR.plugins.copyformatting,l=i.excludedAttributesFromInlineTransform;for(CKEDITOR.env.webkit&&!CKEDITOR.env.chrome&&e.getSelection().selectRanges([t]),a=0;a<n.length;a++)if(t=n[a],-1===o(i.excludedElementsFromInlineTransform,t.element)){if(-1!==o(i.elementsForInlineTransform,t.element))for(t.element=t._.definition.element="span",r=0;r<l.length;r++)t._.definition.attributes[l[r]]&&delete t._.definition.attributes[l[r]];t.apply(e)}},_applyStylesToListContext:function(t,n,o){var a,r,i;for(i=0;i<o.length;i++)a=o[i],r=n.createBookmark(),"ol"===a.element||"ul"===a.element?e(n,{ul:1,ol:1},(function(e){var t=a;e.getName()!==t.element&&e.renameNode(t.element),t.applyToObject(e)}),!0):"li"===a.element?e(n,"li",(function(e){a.applyToObject(e)})):CKEDITOR.plugins.copyformatting._applyStylesToTextContext(t,n,[a]),n.moveToBookmark(r)},_applyStylesToTableContext:function(t,n,a){function r(e,t){e.getName()!==t.element&&((t=t.getDefinition()).element=e.getName(),t=new CKEDITOR.style(t)),t.applyToObject(e)}var i,l,s;for(s=0;s<a.length;s++)i=a[s],l=n.createBookmark(),-1!==o(["table","tr"],i.element)?e(n,i.element,(function(e){i.applyToObject(e)})):-1!==o(["td","th"],i.element)?e(n,{td:1,th:1},(function(e){r(e,i)})):-1!==o(["thead","tbody"],i.element)?e(n,{thead:1,tbody:1},(function(e){r(e,i)})):CKEDITOR.plugins.copyformatting._applyStylesToTextContext(t,n,[i]),n.moveToBookmark(l)},_applyFormat:function(e,t){var n,o,a=e.getSelection().getRanges()[0],r=CKEDITOR.plugins.copyformatting;if(!a)return!1;if(a.collapsed){if(o=e.getSelection().createBookmarks(),!(n=r._getSelectedWordOffset(a)))return;(a=e.createRange()).setStart(n.startNode,n.startOffset),a.setEnd(n.endNode,n.endOffset),a.select()}return t=r._filterStyles(t),!!e.copyFormatting.fire("applyFormatting",{styles:t,range:a,preventFormatStripping:!1},e)&&(o&&e.getSelection().selectBookmarks(o),!0)},_putScreenReaderMessage:function(e,t){var n=this._getScreenReaderContainer();n&&n.setText(e.lang.copyformatting.notification[t])},_addScreenReaderContainer:function(){return this._getScreenReaderContainer()?this._getScreenReaderContainer():CKEDITOR.env.ie6Compat||CKEDITOR.env.ie7Compat?void 0:CKEDITOR.document.getBody().append(CKEDITOR.dom.element.createFromHtml('<div class="cke_screen_reader_only cke_copyformatting_notification"><div aria-live="polite"></div></div>')).getChild(0)},_getScreenReaderContainer:function(){if(!CKEDITOR.env.ie6Compat&&!CKEDITOR.env.ie7Compat)return CKEDITOR.document.getBody().findOne(".cke_copyformatting_notification div[aria-live]")},_attachPasteKeystrokeHandler:function(e){var t=e.config.copyFormatting_keystrokePaste;t&&(this._initialKeystrokePasteCommand=e.keystrokeHandler.keystrokes[t],e.setKeystroke(t,"applyFormatting"))},_detachPasteKeystrokeHandler:function(e){var t=e.config.copyFormatting_keystrokePaste;t&&e.setKeystroke(t,this._initialKeystrokePasteCommand||!1)}},CKEDITOR.config.copyFormatting_outerCursor=!0,CKEDITOR.config.copyFormatting_allowRules="b s u i em strong span p div td th ol ul li(*)[*]{*}",CKEDITOR.config.copyFormatting_disallowRules="*[data-cke-widget*,data-widget*,data-cke-realelement](cke_widget*)",CKEDITOR.config.copyFormatting_allowedContexts=!0,CKEDITOR.config.copyFormatting_keystrokeCopy=CKEDITOR.CTRL+CKEDITOR.SHIFT+67,CKEDITOR.config.copyFormatting_keystrokePaste=CKEDITOR.CTRL+CKEDITOR.SHIFT+86}();