!function(a){a.ui.Factory.add("WPLinkPreview",a.ui.Control.extend({url:"#",renderHtml:function(){return'<div id="'+this._id+'" class="wp-link-preview"><a href="'+this.url+'" target="_blank" rel="noopener" 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\.)?/,""),(c=b.indexOf("?"))!==-1&&(b=b.slice(0,c)),(c=b.indexOf("#"))!==-1&&(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&&(c=b.indexOf("/"))!==-1&&(d=b.lastIndexOf("/"))!==-1&&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.Factory.add("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.getStart(),e=b.dom.getParent(d,"a[href]");returne||(c=b.selection.getContent({format:"raw"}),c&&c.indexOf("</a>")!==-1&&(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){varc=b.$(a),d=c.attr("href");d&&"undefined"!=typeofn&&(s=!1,!/^http/i.test(d)||p.test(d)&&q.test(d)?c.removeAttr("data-wplink-url-error"):(s=!0,c.attr("data-wplink-url-error","true"),r(b.translate("Warning: the link has been inserted but may have errors. Please test it."),"assertive")))}varg,h,i,j,k,l,m,n=window.jQuery,o=/^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i,p=/^https?:\/\/([^\s\/?.#-][^\s\/?.#]*\.?)+(\/[^\s"]*)?$/i,q=/^https?:\/\/[^\/]+\.[^\/]+($|\/)/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){g=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"),h=b.wp._createToolbar(a,!0),h.on("show",function(){"undefined"!=typeofwindow.wpLink&&window.wpLink.modalOpen||window.setTimeout(function(){vara=h.$el.find("input.ui-autocomplete-input")[0],b=k&&(k.textContent||k.innerText);a&&(!a.value&&b&&"undefined"!=typeofwindow.wpLink&&(a.value=window.wpLink.getUrlFromSelection(b)),l||(a.focus(),a.select()))})}),h.on("hide",function(){h.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):(k=c(),h.tempHide=!1,k||(d(),b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),k=b.$('a[href="_wp_link_placeholder"]')[0],b.nodeChanged()),voidb.dom.setAttribs(k,{"data-wplink-edit":!0}))}),b.addCommand("wp_link_apply",function(){if(!h.scrolling){varc,d;if(k){c=j.getURL(),d=j.getLinkText(),b.focus();vare=document.createElement("a");if(e.href=c,"javascript:"!==e.protocol&&"data:"!==e.protocol||(c=""),!c)returnvoidb.dom.remove(k,!0);/^(?:[a-z]+:|#|\?|\.|\/)/.test(c)||o.test(c)||(c="http://"+c),b.dom.setAttribs(k,{href:c,"data-wplink-edit":null}),a.trim(k.innerHTML)||b.$(k)