!function(){var e=/^<a[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>$/i;CKEDITOR.plugins.add("autoembed",{requires:"autolink,undo",lang:"az,bg,ca,cs,da,de,de-ch,el,en,en-au,eo,es,es-mx,et,eu,fr,gl,hr,hu,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)==CKEDITOR.DATA_TRANSFER_INTERNAL)a=0;else{var o=i.data.dataValue.match(e);(a=null!=o&&decodeURI(o[1])==decodeURI(o[2]))&&(i.data.dataValue='<a data-cke-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-cke-autoembed="'+t+'"]'),i=e.lang.autoembed;if(n&&n.data("cke-saved-href")){n=n.data("cke-saved-href");var o=CKEDITOR.plugins.autoEmbed.getWidgetDefinition(e,n);if(o){var d,r="function"==typeof o.defaults?o.defaults():o.defaults,s=(r=CKEDITOR.dom.element.createFromHtml(o.template.output(r)),e.widgets.wrapElement(r,o.name)),l=new CKEDITOR.dom.documentFragment(s.getDocument());l.append(s),(d=e.widgets.initOn(r,o))?(a=e.showNotification(i.embeddingInProgress,"info"),d.loadContent(n,{noNotifications:!0,callback:function(){var n=e.editable().findOne('a[data-cke-autoembed="'+t+'"]');if(n){var i=e.getSelection(),o=e.createRange(),d=e.editable();e.fire("saveSnapshot"),e.fire("lockSnapshot",{dontUpdate:!0});var r=i.createBookmarks(!1)[0],u=r.startNode,f=r.endNode||u;CKEDITOR.env.ie&&9>CKEDITOR.env.version&&!r.endNode&&u.equals(n.getNext())&&n.append(u),o.setStartBefore(n),o.setEndAfter(n),d.insertElement(s,o),d.contains(u)&&d.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(d,!0),e.showNotification(i.embeddingFailed,"info")}})):e.widgets.finalizeCreation(l)}else CKEDITOR.warn("autoembed-no-widget-def")}}(t,n)}))}}),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}}}();