/* 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(){function t(t){var e=t.widgets,n=t.focusManager.currentActive;if(t.focusManager.hasFocus){if(e.focused)return e.focused;if(n instanceof CKEDITOR.plugins.widget.nestedEditable)return e.getByElement(n)}}function e(t,e){return t.features&&-1!==CKEDITOR.tools.array.indexOf(t.features,e)}function n(t,n){return CKEDITOR.tools.array.reduce(CKEDITOR.tools.object.keys(t),function(a,i){var o=t[i];return e(o,n)&&a.push(o),a},[])}function a(t,e){return e=CKEDITOR.tools.object.merge({pathName:t.lang.imagebase.pathName,defaults:{imageClass:t.config.easyimage_class||"",alt:"",src:"",caption:""},template:'
{alt}
{caption}
',allowedContent:{img:{attributes:"!src,alt,width,height"},figure:!0,figcaption:!0},requiredContent:"figure; img[!src]",features:[],editables:{caption:{selector:"figcaption",pathName:t.lang.imagebase.pathNameCaption,allowedContent:"br em strong sub sup u s; a[!href,target]"}},parts:{image:"img",caption:"figcaption"},upcasts:{figure:function(t){return 1===t.find("img",!0).length?t:void 0}}},e),e.upcast=CKEDITOR.tools.object.keys(e.upcasts).join(","),e}function i(t){this.wrapper=CKEDITOR.dom.element.createFromHtml(t||'
')}function o(){i.call(this,'
'),this.bar=this.wrapper.getFirst()}var r=!1,s={caption:function(){function e(t){t.parts.caption.data("cke-caption-placeholder",!1)}function a(t,e){t.data("cke-caption-active",e),t.data("cke-caption-hidden",!e)}return{setUp:function(t){function e(e){var i=(e="blur"===e.name?t.elementPath():e.data.path)?e.lastElement:null;return e=n(t.widgets.instances,"caption"),t.filter.check("figcaption")?void CKEDITOR.tools.array.forEach(e,function(t){t._refreshCaption(i)}):CKEDITOR.tools.array.forEach(a,function(t){t.removeListener()})}var a=[];a.push(t.on("selectionChange",e,null,null,9)),a.push(t.on("blur",e))},init:function(){if(this.editor.filter.check("figcaption")){if(!this.parts.caption){var t=this.parts,e=this.element,n=e.getDocument().createElement("figcaption");e.append(n),this.initEditable("caption",this.definition.editables.caption),t.caption=n}this.editables.caption.getData()||this.parts.caption.data("cke-caption-placeholder")||this._refreshCaption()}},_refreshCaption:function(n){var i=t(this.editor)===this,o=this.parts.caption,r=this.editables.caption;i?(r.getData()||n.equals(o)?(!n||n.equals(o)&&n.data("cke-caption-placeholder"))&&e(this):this.parts.caption.data("cke-caption-placeholder",this.editor.lang.imagebase.captionPlaceholder),a(o,!0)):(!this.editables.caption.getData()||this.parts.caption.data("cke-caption-placeholder"))&&(e(this),a(o,!1))}}}(),upload:function(){var t={progressReporterType:o,setUp:function(e,n){e.on("paste",function(a){var i=a.data.dataTransfer,o=i&&i.isFileTransfer(),r=i&&i.getFilesCount();if(!e.readOnly&&o){var s=[];n=e.widgets.registered[n.name];for(var l=0;r>l;l++)o=i.getFile(l),CKEDITOR.fileTools.isTypeSupported(o,n.supportedTypes)&&s.push(o);0!==s.length&&(a.cancel(),a.stop(),CKEDITOR.tools.array.forEach(s,function(a,i){var o=t._spawnLoader(e,a,n,a.name);t._insertWidget(e,n,URL.createObjectURL(a),!0,{uploadId:o.id}),i!==s.length-1&&(o=e.getSelection().getRanges(),o[0].enlarge(CKEDITOR.ENLARGE_ELEMENT),o[0].collapse(!1))}))}})},init:function(){this.once("ready",function(){var t=this.data.uploadId;"undefined"!=typeof t&&(t=this.editor.uploadRepository.loaders[t])&&this._beginUpload(this,t)})},_isLoaderDone:function(t){return t.xhr&&4===t.xhr.readyState},_spawnLoader:function(t,e,n,a){var i=n.loadMethod||"loadAndUpload";return t=t.uploadRepository.create(e,a,n.loaderType),t[i](n.uploadUrl,n.additionalRequestParameters),t},_beginUpload:function(t,e){function n(){t.isInited()&&t.setData("uploadId",void 0),t.wrapper.removeClass("cke_widget_wrapper_uploading")}function a(){n(),!1!==t.fire("uploadFailed",{loader:e})&&t.editor.widgets.del(t)}var i={uploaded:function(){n(),t.fire("uploadDone",{loader:e})},abort:a,error:a},o=[];o.push(e.on("abort",i.abort)),o.push(e.on("error",i.error)),o.push(e.on("uploaded",i.uploaded)),this.on("destroy",function(){CKEDITOR.tools.array.filter(o,function(t){return t.removeListener(),!1})}),t.setData("uploadId",e.id),!1!==t.fire("uploadStarted",e)&&t.progressReporterType&&(t._isLoaderDone(e)?i[e.status]&&i[e.status]():(t.wrapper.addClass("cke_widget_wrapper_uploading"),i=new t.progressReporterType,t.wrapper.append(i.wrapper),i.bindLoader(e)))},_insertWidget:function(t,e,n,a,i){var o=("function"==typeof e.defaults?e.defaults():e.defaults)||{},o=CKEDITOR.tools.extend({},o);o.src=n,n=CKEDITOR.dom.element.createFromHtml(e.template.output(o));var o=t.widgets.wrapElement(n,e.name),r=new CKEDITOR.dom.documentFragment(o.getDocument());return r.append(o),!1!==a?(t.widgets.initOn(n,e,i),t.widgets.finalizeCreation(r)):n}};return t}(),link:function(){function n(t){t.addMenuGroup("imagebase",10),t.addMenuItem("imagebase",{label:t.lang.link.menu,command:"link",group:"imagebase"})}function a(t,n,a){return function(){if(a&&e(a,"link")){t.stop();var i={};n.commitContent(i),a.setData("link",i)}}}function i(n,a,i){n.getCommand("unlink").on(a,function(a){var o=t(n);o&&e(o,"link")&&(a.stop(),i&&"function"==typeof i&&i(this,o,n),a.cancel())})}return{allowedContent:{a:{attributes:"!href"}},parts:{link:"a"},init:function(){this.editor.plugins.link&&this.editor.contextMenu&&this.on("contextMenu",function(t){this.parts.link&&(t.data.link=t.data.unlink=CKEDITOR.TRISTATE_OFF)})},setUp:function(o){o.plugins.link&&(o.contextMenu&&n(o),o.on("dialogShow",function(n){var i,r,s=t(o),l=n.data;s&&e(s,"link")&&"link"===l._.name&&(i=l.getContentElement("info","linkDisplayText").getElement().getParent().getParent(),l.setupContent(s.data.link||{}),i.hide(),r=l.once("ok",a(n,l,s),null,null,9),l.once("hide",function(){r.removeListener(),i.show()}))}),i(o,"exec",function(t,e,n){e.setData("link",null),t.refresh(n,n.elementPath())}),i(o,"refresh",function(t,e){t.setState(e.parts.link?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED)}))},data:function(t){var e=this.editor,n=t.data.link,a=this.element.findOne("img");if("undefined"==typeof n&&this.parts.link&&this.setData("link",CKEDITOR.plugins.link.parseLinkAttributes(this.editor,this.parts.link)),"undefined"!=typeof n)if(null===n)this.parts.link.remove(!0),this.parts.link=null,delete t.data.link;else{t=this.parts;var i=a.getAscendant("a")||e.document.createElement("a"),e=CKEDITOR.plugins.link.getLinkAttributes(e,n);CKEDITOR.tools.isEmpty(e.set)||i.setAttributes(e.set),e.removed.length&&i.removeAttributes(e.removed),i.contains(a)||(i.replace(a),a.move(i)),t.link=i}}}}()},l=100;i.prototype={updated:function(){},done:function(){this.remove()},aborted:function(){this.remove()},failed:function(){this.remove()},remove:function(){this.wrapper.remove()},bindLoader:function(t){function e(){n&&(CKEDITOR.tools.array.forEach(n,function(t){t.removeListener()}),n=null)}var n=[],a=CKEDITOR.tools.eventsBuffer(l,function(){t.uploadTotal&&this.updated(t.uploaded/t.uploadTotal)},this);n.push(t.on("update",a.input,this)),n.push(t.once("abort",this.aborted,this)),n.push(t.once("uploaded",this.done,this)),n.push(t.once("error",this.failed,this)),n.push(t.once("abort",e)),n.push(t.once("uploaded",e)),n.push(t.once("error",e))}},o.prototype=new i,o.prototype.updated=function(t){t=Math.round(100*t),t=Math.max(t,0),t=Math.min(t,100),this.bar.setStyle("width",t+"%")},CKEDITOR.plugins.add("imagebase",{requires:"widget,filetools",lang:"az,bg,cs,da,de,de-ch,en,en-au,et,fa,fr,gl,hr,hu,it,ku,lt,lv,nb,nl,pl,pt,pt-br,ro,ru,sk,sq,sr,sr-latn,sv,tr,ug,uk,zh,zh-cn",init:function(t){r||(CKEDITOR.document.appendStyleSheet(this.path+"styles/imagebase.css"),r=!0),t.addContentsCss&&t.addContentsCss(this.path+"styles/imagebase.css")}}),CKEDITOR.plugins.imagebase={featuresDefinitions:s,addImageWidget:function(t,e,n){e=t.widgets.add(e,a(t,n)),t.addFeature(e)},addFeature:function(t,e,n){function a(t,e){return t||e?function(){t&&t.apply(this,arguments),e&&e.apply(this,arguments)}:void 0}var i=CKEDITOR.tools.clone(this.featuresDefinitions[e]);return i.init=a(n.init,i.init),i.data=a(n.data,i.data),i.setUp&&(i.setUp(t,n),delete i.setUp),t=CKEDITOR.tools.object.merge(n,i),CKEDITOR.tools.isArray(t.features)||(t.features=[]),t.features.push(e),t},progressBar:o,progressReporter:i}}();