!function(a){a.ui.WPLinkPreview=a.ui.Control.extend({url:"#",renderHtml:function(){return'<div id="'+this._id+'" class="wp-link-preview"><a href="'+this.url+'" target="_blank" tabindex="-1">'+this.url+"</a></div>"},setURL:function(b){varc,d;this.url!==b&&(this.url=b,b=window.decodeURIComponent(b),b=b.replace(/^(?:https?:)?\/\/(?:www\.)?/,""),-1!==(c=b.indexOf("?"))&&(b=b.slice(0,c)),-1!==(c=b.indexOf("#"))&&(b=b.slice(0,c)),b=b.replace(/(?:index)?\.html$/,""),"/"===b.charAt(b.length-1)&&(b=b.slice(0,-1)),""===b&&(b=this.url),b.length>40&&-1!==(c=b.indexOf("/"))&&-1!==(d=b.lastIndexOf("/"))&&d!==c&&(c+b.length-d<40&&(d=-(40-(c+1))),b=b.slice(0,c+1)+"\u2026"+b.slice(d)),a.$(this.getEl().firstChild).attr("href",this.url).text(b))}}),a.ui.WPLinkInput=a.ui.Control.extend({renderHtml:function(){return'<div id="'+this._id+'" class="wp-link-input"><input type="text" value="" placeholder="'+a.translate("Paste URL or type to search")+'" /><input type="text" style="display:none" value="" /></div>'},setURL:function(a){this.getEl().firstChild.value=a},getURL:function(){returna.trim(this.getEl().firstChild.value)},getLinkText:function(){varb=this.getEl().firstChild.nextSibling.value;returna.trim(b)?b.replace(/[\r\n\t ]+/g," "):""},reset:function(){vara=this.getEl().firstChild;a.value="",a.nextSibling.value=""}}),a.PluginManager.add("wplink",function(b){functionc(){vara,c,d=b.selection.getNode(),e=b.dom.getParent(d,"a[href]");returne||(c=b.selection.getContent({format:"raw"}),c&&-1!==c.indexOf("</a>")&&(a=c.match(/href="([^">]+)"/),a&&a[1]&&(e=b.$('a[href="'+a[1]+'"]',d)[0]),e&&b.selection.select(e))),e}functiond(){b.$("a").each(function(a,c){vard=b.$(c);"_wp_link_placeholder"===d.attr("href")?b.dom.remove(c,!0):d.attr("data-wplink-edit")&&d.attr("data-wplink-edit",null)})}functione(a,b){returna.replace(/(<a [^>]+>)([\s\S]*?)<\/a>/g,function(a,c,d){returnc.indexOf(' href="_wp_link_placeholder"')>-1?d:(b&&(c=c.replace(/ data-wplink-edit="true"/g,"")),c=c.replace(/ data-wplink-url-error="true"/g,""),c+d+"</a>")})}functionf(a){s=!0,a.attr("data-wplink-url-error","true"),r(b.translate("Warning: the link has been inserted but the destination cannot be reached."),"assertive"),h&&h.visible()&&h.$el.find(".wp-link-preview a").addClass("wplink-url-error")}functiong(a){varc=b.$(a),d=c.attr("href");if(d&&"undefined"!=typeofo){if(s=!1,/^http/i.test(d)&&!/^https?:\/\/[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}(\/|$)/i.test(d)&&(p[d]=!0),p.hasOwnProperty(d))returnvoidf(c);c.removeAttr("data-wplink-url-error"),o.post(window.ajaxurl,{action:"test_url",nonce:o("#_wplink_urltest_nonce").val(),href:d},"json").done(function(a){a.success||a.data&&a.data.httpError&&(p[d]=!0,f(c))})}}varh,i,j,k,l,m,n,o=window.jQuery,p={},q=/^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i,r="undefined"!=typeofwindow.wp&&window.wp.a11y&&window.wp.a11y.speak?window.wp.a11y.speak:function(){},s=!1;returnb.on("preinit",function(){if(b.wp&&b.wp._createToolbar){h=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0);vara=["wp_link_input","wp_link_apply"];"undefined"!=typeofwindow.wpLink&&a.push("wp_link_advanced"),i=b.wp._createToolbar(a,!0),i.on("show",function(){"undefined"!=typeofwindow.wpLink&&window.wpLink.modalOpen||window.setTimeout(function(){vara=i.$el.find("input.ui-autocomplete-input")[0],b=l&&(l.textContent||l.innerText);a&&(!a.value&&b&&"undefined"!=typeofwindow.wpLink&&(a.value=window.wpLink.getUrlFromSelection(b)),m||(a.focus(),a.select()))})}),i.on("hide",function(){i.scrolling||b.execCommand("wp_link_cancel")})}}),b.addCommand("WP_Link",function(){returna.Env.ie&&a.Env.ie<10&&"undefined"!=typeofwindow.wpLink?voidwindow.wpLink.open(b.id):(l=c(),i.tempHide=!1,void(l?b.dom.setAttribs(l,{"data-wplink-edit":!0}):(d(),b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),l=b.$('a[href="_wp_link_placeholder"]')[0],b.nodeChanged())))}),b.addCommand("wp_link_apply",function(){if(!i.scrolling){varc,d;if(l){if(c=k.getURL(),d=k.getLinkText(),b.focus(),!c)returnvoidb.dom.remove(l,!0);/^(?:[a-z]+:|#|\?|\.|\/)/.