]+>)?]+>(?:<\/a>)?)([\s\S]*<\/p>)?[\s\S]*/gi,"
$1
$2")),c)})}function g(b){var c,d,e,f,g,h,i,j,k=[],l=a.dom,m=/^\d+$/;return e={attachment_id:!1,size:"custom",caption:"",align:"none",extraClasses:"",link:!1,linkUrl:"",linkClassName:"",linkTargetBlank:!1,linkRel:"",title:""},e.url=l.getAttrib(b,"src"),e.alt=l.getAttrib(b,"alt"),e.title=l.getAttrib(b,"title"),i=l.getAttrib(b,"width"),j=l.getAttrib(b,"height"),(!m.test(i)||parseInt(i,10)<1)&&(i=b.naturalWidth||b.width),(!m.test(j)||parseInt(j,10)<1)&&(j=b.naturalHeight||b.height),e.customWidth=e.width=i,e.customHeight=e.height=j,c=tinymce.explode(b.className," "),d=[],tinymce.each(c,function(a){/^wp-image/.test(a)?e.attachment_id=parseInt(a.replace("wp-image-",""),10):/^align/.test(a)?e.align=a.replace("align",""):/^size/.test(a)?e.size=a.replace("size-",""):d.push(a)}),e.extraClasses=d.join(" "),f=l.getParents(b,".wp-caption"),f.length&&(f=f[0],c=f.className.split(" "),tinymce.each(c,function(a){/^align/.test(a)?e.align=a.replace("align",""):a&&"wp-caption"!==a&&k.push(a)}),e.captionClassName=k.join(" "),g=l.select("dd.wp-caption-dd",f),g.length&&(g=g[0],e.caption=a.serializer.serialize(g).replace(/
]*>/g,"$&\n").replace(/^/,"").replace(/<\/p>$/,""))),b.parentNode&&"A"===b.parentNode.nodeName&&(h=b.parentNode,e.linkUrl=l.getAttrib(h,"href"),e.linkTargetBlank="_blank"===l.getAttrib(h,"target")?!0:!1,e.linkRel=l.getAttrib(h,"rel"),e.linkClassName=h.className),e}function h(a){return a&&!(!a.textContent&&!a.innerText)}function i(b){return!b||-1===b.indexOf("<")&&-1===b.indexOf(">")?b:(n||(n=new tinymce.html.Serializer({},a.schema)),n.serialize(a.parser.parse(b,{forced_root_block:!1})))}function j(b,c){var d,e,f,g,j,k,l,m,n,o,p,q,r,s,t,u,v=a.dom;d=tinymce.explode(c.extraClasses," "),d||(d=[]),c.caption||d.push("align"+c.align),c.attachment_id&&(d.push("wp-image-"+c.attachment_id),c.size&&"custom"!==c.size&&d.push("size-"+c.size)),s=c.width,t=c.height,"custom"===c.size&&(s=c.customWidth,t=c.customHeight),q={src:c.url,width:s||null,height:t||null,alt:c.alt,title:c.title||null,"class":d.join(" ")||null},v.setAttribs(b,q),r={href:c.linkUrl,rel:c.linkRel||null,target:c.linkTargetBlank?"_blank":null,"class":c.linkClassName||null},b.parentNode&&"A"===b.parentNode.nodeName&&!h(b.parentNode)?c.linkUrl?v.setAttribs(b.parentNode,r):v.remove(b.parentNode,!0):c.linkUrl&&((l=v.getParent(b,"a"))&&v.insertAfter(b,l),l=v.create("a",r),b.parentNode.insertBefore(l,b),l.appendChild(b)),m=a.dom.getParent(b,".mceTemp"),f=b.parentNode&&"A"===b.parentNode.nodeName&&!h(b.parentNode)?b.parentNode:b,c.caption?(c.caption=i(c.caption),p=c.attachment_id?"attachment_"+c.attachment_id:null,u="align"+(c.align||"none"),e="wp-caption "+u,c.captionClassName&&(e+=" "+c.captionClassName.replace(/[<>&]+/g,"")),a.getParam("wpeditimage_html5_captions")||(s=parseInt(s,10),s+=10),m?(o=v.select("dl.wp-caption",m),o.length&&v.setAttribs(o,{id:p,"class":e,style:"width: "+s+"px"}),n=v.select(".wp-caption-dd",m),n.length&&v.setHTML(n[0],c.caption)):(p=p?'id="'+p+'" ':"",g="
- '+c.caption+"
",k=v.create("div",{"class":"mceTemp"},g),(j=v.getParent(f,"p"))?(j.parentNode.insertBefore(k,j),v.isEmpty(j)&&v.remove(j)):f.parentNode.insertBefore(k,f),a.$(k).find("dt.wp-caption-dt").append(f))):m&&(j=v.create("p"),m.parentNode.insertBefore(j,m),j.appendChild(f),v.remove(m)),wp.media.events&&wp.media.events.trigger("editor:image-update",{editor:a,metadata:c,image:b}),a.nodeChanged()}function k(b){var c,d,e;return"undefined"!=typeof wp&&wp.media?(e=g(b),wp.media.events.trigger("editor:image-edit",{editor:a,metadata:e,image:b}),c=wp.media({frame:"image",state:"image-details",metadata:e}),wp.media.events.trigger("editor:frame-create",{frame:c}),d=function(d){a.focus(),a.undoManager.transact(function(){j(b,d)}),c.detach()},c.state("image-details").on("update",d),c.state("replace-image").on("replace",d),c.on("close",function(){a.focus(),c.detach()}),void c.open()):void a.execCommand("mceImage")}function l(b){var c;"DIV"===b.nodeName&&a.dom.hasClass(b,"mceTemp")?c=b:("IMG"===b.nodeName||"DT"===b.nodeName||"A"===b.nodeName)&&(c=a.dom.getParent(b,"div.mceTemp")),c?(a.selection.select(c.nextSibling?c.nextSibling:c.previousSibling?c.previousSibling:c.parentNode),a.selection.collapse(!0),a.dom.remove(c)):a.dom.remove(b),a.nodeChanged(),a.undoManager.add()}var m,n,o=tinymce.DOM,p=a.settings,q=tinymce.ui.Factory,r=tinymce.each,s=tinymce.Env.iOS,t=!0,u=tinymce.$("#postdivrich");return a.addButton("wp_img_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){l(a.selection.getNode())}}),a.addButton("wp_img_edit",{tooltip:"Edit",icon:"dashicon dashicons-edit",onclick:function(){k(a.selection.getNode())}}),r({alignleft:"Align left",aligncenter:"Align center",alignright:"Align right",alignnone:"No alignment"},function(b,c){var d=c.slice(5);a.addButton("wp_img_"+c,{tooltip:b,icon:"dashicon dashicons-align-"+d,cmd:"alignnone"===c?"wpAlignNone":"Justify"+d.slice(0,1).toUpperCase()+d.slice(1),onPostRender:function(){var b=this;a.on("NodeChange",function(d){var e;"IMG"===d.element.nodeName&&(e=a.dom.getParent(d.element,".wp-caption")||d.element,b.active("alignnone"===c?!/\balign(left|center|right)\b/.test(e.className):a.dom.hasClass(e,c)))})}})}),m=q.create(c()).renderTo(document.body).hide(),m.reposition=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,p,q,r,t,u,v,w,x,y=this.getEl(),z=5,A=8,B=0,C=a.selection.getNode();return C&&"IMG"===C.nodeName?(f=window.pageYOffset||document.documentElement.scrollTop,g=tinymce.$("#wpadminbar")[0],h=tinymce.$(".mce-tinymce .mce-toolbar-grp")[0],i=C.getBoundingClientRect(),j=(i.left+i.right)/2,k=(i.top+i.bottom)/2,l=i.top,m=v-i.bottom,n=window.innerWidth,p=y.offsetWidth,q=p/2,r=a.getContentAreaContainer().firstChild,t=o.getPos(r),u=r.offsetWidth,v=r.offsetHeight,w=y.offsetHeight,x=w+A+z,s?b=i.top+t.y+A:l>=x?(e=" mce-arrow-down",b=i.top+t.y-w-A):m>=x?(e=" mce-arrow-up",b=i.bottom+t.y):(b=z,e=k>=x?" mce-arrow-down":" mce-arrow-up"),d=h?o.getPos(h).y+h.clientHeight:t.y,f&&(g&&0===g.getBoundingClientRect().top&&(B=g.clientHeight),f+B>d&&(d=f+B)),b&&d&&d+z>b&&(b=d+z,e=""),c=j-q,c+=t.x,p>=n?(e+=" mce-arrow-full",c=0):0>c&&i.left+p>n||c+p>n&&i.right-p<0?c=(n-p)/2:cu+t.x&&(e+=" mce-arrow-right",c=i.right-p+t.x),s||(y.className=y.className.replace(/ ?mce-arrow-[\w]+/g,""),y.className+=e),o.setStyles(y,{left:c,top:b}),this):this},s&&a.on("click",function(b){if("IMG"===b.target.nodeName){var c=b.target;window.setTimeout(function(){a.selection.select(c)},200)}else m.hide()}),a.on("nodechange",function(c){var d=s?350:100;return"IMG"!==c.element.nodeName||b(c.element)?void m.hide():void setTimeout(function(){var c=a.selection.getNode();"IMG"!==c.nodeName||b(c)?m.hide():m._visible?m.reposition():m.show()},d)}),m.on("show",function(){var a=this;t=!1,setTimeout(function(){a._visible&&(o.addClass(a.getEl(),"mce-inline-toolbar-grp-active"),a.reposition())},100)}),m.on("hide",function(){t=!0,o.removeClass(this.getEl(),"mce-inline-toolbar-grp-active")}),o.bind(window,"resize scroll",function(){!t&&u.hasClass("wp-editor-expand")&&d()}),a.on("init",function(){a.dom.bind(a.getWin(),"scroll",d)}),a.on("blur hide",d),a.shortcuts.add("Alt+119","",function(){var a=m.find("toolbar")[0];a&&a.focus(!0)}),a.on("init",function(){var b=a.dom,c=a.getParam("wpeditimage_html5_captions")?"html5-captions":"html4-captions";b.addClass(a.getBody(),c),a.on("wpLoadImageForm",function(b){if(!a.getParam("wpeditimage_disable_captions")){var c={type:"textbox",flex:1,name:"caption",minHeight:60,multiline:!0,scroll:!0,label:"Image caption"};b.data.splice(b.data.length-1,0,c)}}),a.on("wpNewImageRefresh",function(a){var c,d;(c=b.getParent(a.node,"dl.wp-caption"))&&(c.style.width||(d=parseInt(a.node.clientWidth,10)+10,d=d?d+"px":"50%",b.setStyle(c,"width",d)))}),a.on("wpImageFormSubmit",function(c){var d,e,f,g,h,j=c.imgData.data,k=c.imgData.node,l=c.imgData.caption,m="",n="",o="";return j.id="__wp-temp-img-id",c.imgData.cancel=!0,j.style||(j.style=null),j.src?(l&&(l=l.replace(/\r\n|\r/g,"\n").replace(/<\/?[a-zA-Z0-9]+( [^<>]+)?>/g,function(a){return a.replace(/[\r\n\t]+/," ")}),l=l.replace(/(
]*>)\s*\n\s*/g,"$1").replace(/\s*\n\s*/g,"
"),l=i(l)),k?(h=k.id||null,b.setAttribs(k,j),d=b.getParent(k,"dl.wp-caption"),l?d?(e=b.select("dd.wp-caption-dd",d)[0])&&(e.innerHTML=l):(k.className&&(m=k.className.match(/wp-image-([0-9]+)/),n=k.className.match(/align(left|right|center|none)/)),n?(n=n[0],k.className=k.className.replace(/align(left|right|center|none)/g,"")):n="alignnone",n=' class="wp-caption '+n+'"',m&&(m=' id="attachment_'+m[1]+'"'),o=j.width||k.clientWidth,o&&(o=parseInt(o,10),a.getParam("wpeditimage_html5_captions")||(o+=10),o=' style="width: '+o+'px"'),f=k.parentNode&&"A"===k.parentNode.nodeName?k.parentNode:k,g="- '+l+"
",d=b.create("div",{"class":"mceTemp"},g),(e=b.getParent(f,"p"))?(e.parentNode.insertBefore(d,e),b.isEmpty(e)&&b.remove(e)):f.parentNode.insertBefore(d,f),a.$(d).find("dt.wp-caption-dt").append(f)):d&&(g=b.getOuterHTML("A"===k.parentNode.nodeName?k.parentNode:k),e=b.create("p",{},g),b.insertAfter(e,d.parentNode),a.selection.select(e),a.nodeChanged(),b.remove(d.parentNode))):(g=b.createHTML("img",j),l?(f=a.selection.getNode(),j.width&&(o=parseInt(j.width,10),a.getParam("wpeditimage_html5_captions")||(o+=10),o=' style="width: '+o+'px"'),g='- '+g+'
- '+l+"
",e="P"===f.nodeName?f:b.getParent(f,"p"),e&&"P"===e.nodeName?(d=b.create("div",{"class":"mceTemp"},g),e.parentNode.insertBefore(d,e),a.selection.select(d),a.nodeChanged(),b.isEmpty(e)&&b.remove(e)):a.selection.setContent(''+g+"
")):a.selection.setContent(g)),k=b.get("__wp-temp-img-id"),b.setAttrib(k,"id",h),void(c.imgData.node=k)):void(k&&(b.remove((d=b.getParent(k,"div.mceTemp"))?d:"A"===k.parentNode.nodeName?k.parentNode:k),a.nodeChanged()))}),a.on("wpLoadImageData",function(c){var d,e=c.imgData.data,f=c.imgData.node;(d=b.getParent(f,"dl.wp-caption"))&&(d=b.select("dd.wp-caption-dd",d)[0],d&&(e.caption=a.serializer.serialize(d).replace(/
]*>/g,"$&\n").replace(/^/,"").replace(/<\/p>$/,"")))}),b.bind(a.getDoc(),"dragstart",function(c){var d=a.selection.getNode();"IMG"===d.nodeName&&b.getParent(d,".wp-caption")&&c.preventDefault()}),tinymce.Env.ie&&tinymce.Env.ie>10&&b.bind(a.getBody(),"mscontrolselect",function(c){"IMG"===c.target.nodeName&&b.getParent(c.target,".wp-caption")?a.getBody().focus():"DL"===c.target.nodeName&&b.hasClass(c.target,"wp-caption")&&c.target.focus()})}),a.on("ObjectResized",function(b){var c=b.target;"IMG"===c.nodeName&&a.undoManager.transact(function(){var d,e,f=a.dom;c.className=c.className.replace(/\bsize-[^ ]+/,""),(d=f.getParent(c,".wp-caption"))&&(e=b.width||f.getAttrib(c,"width"),e&&(e=parseInt(e,10),a.getParam("wpeditimage_html5_captions")||(e+=10),f.setStyle(d,"width",e+"px")))})}),a.on("BeforeExecCommand",function(b){var c,d,e,f,g,h=b.command,i=a.dom;if("mceInsertContent"===h)(c=i.getParent(a.selection.getNode(),"div.mceTemp"))&&(d=i.create("p"),i.insertAfter(d,c),a.selection.setCursorLocation(d,0),a.nodeChanged());else if("JustifyLeft"===h||"JustifyRight"===h||"JustifyCenter"===h||"wpAlignNone"===h){if(c=a.selection.getNode(),f="align"+h.slice(7).toLowerCase(),e=a.dom.getParent(c,".wp-caption"),"IMG"!==c.nodeName&&!e)return;c=e||c,g=a.dom.hasClass(c,f)?" alignnone":" "+f,c.className=c.className.replace(/ ?align(left|center|right|none)/g,"")+g,a.nodeChanged(),b.preventDefault(),m&&m.reposition()}}),a.on("keydown",function(b){var c,d,e,f,g=a.selection,h=b.keyCode,i=a.dom,j=tinymce.util.VK;if(h===j.ENTER)c=g.getNode(),d=i.getParent(c,"div.mceTemp"),d&&(i.events.cancel(b),tinymce.each(i.select("dt, dd",d),function(a){i.isEmpty(a)&&i.remove(a)}),f=tinymce.Env.ie&&tinymce.Env.ie<11?"":'
',e=i.create("p",null,f),"DD"===c.nodeName?i.insertAfter(e,d):d.parentNode.insertBefore(e,d),a.nodeChanged(),g.setCursorLocation(e,0));else if((h===j.DELETE||h===j.BACKSPACE)&&(c=g.getNode(),"DIV"===c.nodeName&&i.hasClass(c,"mceTemp")?d=c:("IMG"===c.nodeName||"DT"===c.nodeName||"A"===c.nodeName)&&(d=i.getParent(c,"div.mceTemp")),d))return i.events.cancel(b),l(c),!1}),tinymce.Env.gecko&&a.on("undo redo",function(){"IMG"===a.selection.getNode().nodeName&&a.selection.collapse()}),a.wpSetImgCaption=function(a){return e(a)},a.wpGetImgCaption=function(a){return f(a)},a.on("BeforeSetContent",function(b){"raw"!==b.format&&(b.content=a.wpSetImgCaption(b.content))}),a.on("PostProcess",function(b){b.get&&(b.content=a.wpGetImgCaption(b.content))}),{_do_shcode:e,_get_shcode:f}});