!function(){var e=/^<a[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>$/i;NEW_CKEDITOR.plugins.add("autoembed",{requires:"autolink,undo",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,km,ko,ku,lt,lv,mk,nb,nl,oc,pl,pt,pt-br,ro,ru,sk,sq,sr,sr-latn,sv,tr,ug,uk,vi,zh,zh-cn",init:function(t){var a,n=1;t.on("paste",(function(i){if(i.data.dataTransfer.getTransferType(t)==NEW_CKEDITOR.DATA_TRANSFER_INTERNAL)a=0;else{var d=i.data.dataValue.match(e);(a=null!=d&&decodeURI(d[1])==decodeURI(d[2]))&&(i.data.dataValue='<a data-edi-autoembed="'+ ++n+'"'+i.data.dataValue.substr(2))}}),null,null,20),t.on("afterPaste",(function(){a&&function(e,t){var a,n=e.editable().findOne('a[data-edi-autoembed="'+t+'"]'),i=e.lang.autoembed;if(n&&n.data("edi-saved-href")){n=n.data("edi-saved-href");var d=NEW_CKEDITOR.plugins.autoEmbed.getWidgetDefinition(e,n);if(d){var o,r="function"==typeof d.defaults?d.defaults():d.defaults,s=(r=NEW_CKEDITOR.dom.element.createFromHtml(d.template.output(r)),e.widgets.wrapElement(r,d.name)),l=new NEW_CKEDITOR.dom.documentFragment(s.getDocument());l.append(s),(o=e.widgets.initOn(r,d))?(a=e.showNotification(i.embeddingInProgress,"info"),o.loadContent(n,{noNotifications:!0,callback:function(){var n=e.editable().findOne('a[data-edi-autoembed="'+t+'"]');if(n){var i=e.getSelection(),d=e.createRange(),o=e.editable();e.fire("saveSnapshot"),e.fire("lockSnapshot",{dontUpdate:!0});var r=i.createBookmarks(!1)[0],u=r.startNode,f=r.endNode||u;NEW_CKEDITOR.env.ie&&9>NEW_CKEDITOR.env.version&&!r.endNode&&u.equals(n.getNext())&&n.append(u),d.setStartBefore(n),d.setEndAfter(n),o.insertElement(s,d),o.contains(u)&&o.contains(f)?i.selectBookmarks([r]):(u.remove(),f.remove()),e.fire("unlockSnapshot")}a.hide(),e.widgets.finalizeCreation(l)},errorCallback:function(){a.hide(),e.widgets.destroy(o,!0),e.showNotification(i.embeddingFailed,"info")}})):e.widgets.finalizeCreation(l)}else NEW_CKEDITOR.warn("autoembed-no-widget-def")}}(t,n)}))}}),NEW_CKEDITOR.plugins.autoEmbed={getWidgetDefinition:function(e,t){var a,n=e.config.autoEmbed_widget||"embed,embedSemantic",i=e.widgets.registered;if("string"==typeof n){for(n=n.split(",");a=n.shift();)if(i[a])return i[a]}else if("function"==typeof n)return i[n(t)];return null}}}();