!function(){var e={_attachScript:function(e,t){var n=new NEW_CKEDITOR.dom.element("script");return n.setAttribute("src",e),n.on("error",t),NEW_CKEDITOR.document.getBody().append(n),n},sendRequest:function(e,t,n,a){function s(){o&&(o.remove(),delete NEW_CKEDITOR._.jsonpCallbacks[r],o=null)}var i={};t=t||{};var o,r=NEW_CKEDITOR.tools.getNextNumber();return t.callback="NEW_CKEDITOR._.jsonpCallbacks["+r+"]",NEW_CKEDITOR._.jsonpCallbacks[r]=function(e){setTimeout((function(){s(),n(e)}))},o=this._attachScript(e.output(t),(function(){s(),a&&a()})),i.cancel=s,i}};NEW_CKEDITOR.plugins.add("embedbase",{lang:"ar,az,bg,ca,cs,da,de,de-ch,el,en,en-au,eo,es,es-mx,et,eu,fa,fr,gl,hr,hu,id,it,ja,ko,ku,lv,nb,nl,oc,pl,pt,pt-br,ro,ru,sk,sq,sr,sr-latn,sv,tr,ug,uk,zh,zh-cn",requires:"dialog,widget,notificationaggregator",onLoad:function(){NEW_CKEDITOR._.jsonpCallbacks={}},init:function(){NEW_CKEDITOR.dialog.add("embedBase",this.path+"dialogs/embedbase.js")}}),NEW_CKEDITOR.plugins.embedBase={createWidgetBaseDefinition:function(t){var n,a=t.lang.embedbase;return{mask:!0,template:"<div></div>",pathName:a.pathName,_cache:{},urlRegExp:/^((https?:)?\/\/|www\.)/i,init:function(){this.on("sendRequest",(function(e){this._sendRequest(e.data)}),this,null,999),this.on("handleResponse",(function(e){if(!e.data.html){var t=this._responseToHtml(e.data.url,e.data.response);null!==t?e.data.html=t:(e.data.errorMessage="unsupportedUrl",e.cancel())}}),this,null,999)},loadContent:function(e,t){function n(n){i.response=n,a.editor.widgets.instances[a.id]?a._handleResponse(i)&&(a._cacheResponse(e,n),t.callback&&t.callback()):(NEW_CKEDITOR.warn("embedbase-widget-invalid"),i.task&&i.task.done())}t=t||{};var a=this,s=this._getCachedResponse(e),i={noNotifications:t.noNotifications,url:e,callback:n,errorCallback:function(e){a._handleError(i,e),t.errorCallback&&t.errorCallback(e)}};if(!s)return t.noNotifications||(i.task=this._createTask()),this.fire("sendRequest",i),i;setTimeout((function(){n(s)}))},isUrlValid:function(e){return this.urlRegExp.test(e)&&!1!==this.fire("validateUrl",e)},getErrorMessage:function(e,n,a){return(a=t.lang.embedbase[e+(a||"")])||(a=e),new NEW_CKEDITOR.template(a).output({url:n||""})},_sendRequest:function(t){var n=this,a=e.sendRequest(this.providerUrl,{url:encodeURIComponent(t.url)},t.callback,(function(){t.errorCallback("fetchingFailed")}));t.cancel=function(){a.cancel(),n.fire("requestCanceled",t)}},_handleResponse:function(e){var t={url:e.url,html:"",response:e.response};return!1!==this.fire("handleResponse",t)?(e.task&&e.task.done(),this._setContent(e.url,t.html),!0):(e.errorCallback(t.errorMessage),!1)},_handleError:function(e,n){e.task&&(e.task.cancel(),e.noNotifications||t.showNotification(this.getErrorMessage(n,e.url),"warning"))},_responseToHtml:function(e,t){return"photo"==t.type?'<img src="'+NEW_CKEDITOR.tools.htmlEncodeAttr(t.url)+'" alt="'+NEW_CKEDITOR.tools.htmlEncodeAttr(t.title||"")+'" style="max-width:100%;height:auto" />':"video"==t.type||"rich"==t.type?(t.html=t.html.replace(/<iframe/g,'<iframe tabindex="-1"'),t.html):null},_setContent:function(e,t){this.setData("url",e),this.element.setHtml(t)},_createTask:function(){return n&&!n.isFinished()||(n=new NEW_CKEDITOR.plugins.notificationAggregator(t,a.fetchingMany,a.fetchingOne)).on("finished",(function(){n.notification.hide()})),n.createTask()},_cacheResponse:function(e,t){this._cache[e]=t},_getCachedResponse:function(e){return this._cache[e]}}},_jsonp:e}}();